Question

Is it possible to create a DropDownListRow on a form that has no $model parameter? I want to have users select from a list of controller Actions using a DropDownListRow (the YiiBooster variant of DropDownList). I'm just working with a list of Actions from the Controller, so I don't need a $model in the widget parameters.

The problem is that Yii won't create a form unless there is a $model associated with it. I want the user to select the controller Action, and then have the associated subform open based on the Action the user choose.

Était-ce utile?

La solution

addition to @ramamoorthy_villi answer

to create a dropdown list, simply use CHtml s dropdownList() function, then you can have your dropdown filled with your own data,

$data = array(
    'selected_value' => 'defaultController/action',
    '2' => 'controller2/action',
    '3' => 'controller3/action',
)

echo CHtml::dropdownList('Name' , 'selected_value' , $data);

now you have it with defaultController/action pre selected

Autres conseils

To create form without model object http://www.yiiframework.com/doc/guide/1.1/en/form.view

<div class="form">
<?php echo CHtml::beginForm(); ?>


<?php echo CHtml::endForm(); ?>
</div><!-- form -->

To get the Meta data : list of actions for a controller Use this extension

http://www.yiiframework.com/extension/metadata/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top