Hi,
I am new to YII and frameworks in general. I am trying to create a drop down list in my view with the possible values for my model.
I have a model called ‘State’ with an attribute called ‘order’. I have defined in the rules so that ‘order’ must be an integer with a minimum value of -10 and a maximum of 10. I want a dropdown for the ‘order’ in the view.
Obviously, I could write the drop down with these values hard coded:
$range = array();
foreach(range(-10, 10) as $value){
$range[$value] = $value;
}
echo $form->dropDownList($model, 'order', $range);
But it would be better to ask the State model what the possible values are for the order attribute. Or at least what the min and max are. So that when they change, I don’t have to update the view. Is this possible?
Thanks
Brendan