Hello all,
I’m having trouble creating a dropdownlist for a form model.
Specifically, the field of the dropdownlist is being posted outside the model array.
My model has 3 fields that have to be filled with the following form
<?php echo CHtml::beginForm($this->createUrl('prova/index'),'post', array('id'=>"create-shop-form") ); ?>
<?php echo CHtml::activeTextField($model,'name', array('class' => 'form-control')) ?>
<?php echo CHtml::activeTextField($model,'scode', array('class' => 'form-control', 'placeholder'=>'url_de_la_botiga')) ?>
<?php
$options = array ('€' => '€');
echo CHtml::dropDownList('currency', $model, $options, array('class' => 'form-control')); ?>
<button type="submit" class="btn btn-primary">Create</button>
<?php echo CHtml::endForm(); ?>
And this is what I receive in the controller. As you see, ‘currency’ is outside the array.
array (size=3)
'YII_CSRF_TOKEN' => string 'f1b0dfe495558ede162157589409b8b1c536e6c1' (length=40)
'Shop' =>
array (size=2)
'name' => string 'whatever' (length=0)
'scode' => string 'whatever' (length=0)
'currency' => string 'euro' (length=3)
Which way I have to follow to link this dropdownlist to the model?
Thanks