0

CDetailView 属性にドロップダウンを配置する必要があり、属性値はデータベースから取得されます。ユーザーが値ドロップダウンを選択すると、選択した値を持つ別のページにリダイレクトされます。

誰でもそれを行う方法を知っていますか、クイックガイドが必要です

4

2 に答える 2

2
<form>  <!-- A form to make the submit work. -->
<?php 
$profile = Profile::model()->findByPk(1);
$this->widget('zii.widgets.CDetailView', array(
    'data'=>$profile,
    'attributes'=>array('id','name',
        array(
            'label'=>'email addresses',
            'type'=>'raw',
            'value'=>CHtml::dropDownList('id', '', 
                CHtml::listData($profile->emails, 'id', 'value'),
                array(
                    'submit'=>['Site/Index'],
                    // 'onchange'=>'js:something'.  // You can trigger some javascript here instead of the submit - but it's more hassle if you ask me.
                    'prompt'=>'-- You\'ll need a prompt' // Because onchange wont fire for the initially selected item.
                )
            )
        ),
    ),
)); ?>
</form>
于 2013-06-11T01:06:55.450 に答える