I have two fields which saved in the database (in this case would be to review the application in magento, but that does not matter much). These fields are being saved correctly, but with a problem, it saves one of the fields written array
. The datum and address type fields are saved correctly.
HTML code for fields:
<div class="field small small-left left">
<label for="comments"><?php echo $this->__('Referência: ') ?></label>
<div class="input-box">
<input style="width: 100% !important;" class="input-text" id="comments_1" name="comments[]" title="<?php echo $this->__('Pontos de Referência') ?>" />
</div>
</div>
<div class="field info">
<label for="commentsEnd" class="tipoEnd">Tipo de Endereço:</label>
<div class="input-box">
<div class="styled-select">
<select id="comments_2" name="comments[]" title="<?php echo $this->__('Tipo de Endereço') ?>" class="onestep">
<option value="">Selecione</option>
<option value="residencial">Residencial</option>
<option value="comercial">Comercial</option>
</select>
</div>
</div>
code in the module Model, which runs the Array
and saves the fields:
if (!empty($oscOrderData['comments'])) {
$order = $observer->getEvent()->getOrder();
/* @var $order Mage_Sales_Model_Order */
// Force array type
if(!is_array($oscOrderData['comments']))
$oscOrderData['comments'] = array($oscOrderData['comments']);
foreach($oscOrderData['comments'] as $comment) {
$order->addStatusHistoryComment($comment);
}
$order->save();
}