inverse
(Arpitjindal 87)
December 4, 2011, 12:19pm
1
Hi All
I have created a dependent DropDownList using http://www.yiiframework.com/wiki/24/creating-a-dependent-dropdown/ . Now the problem I am facing is When I have to update the form then I have to select the values of all drop down list again. Since there are around 5-6 dependent drop down list so it is a little problematic. Is there any way with which i don’t have to select it again and again while updating a form.
Thanks.
inverse
(Arpitjindal 87)
December 15, 2011, 5:30pm
2
Hi All
Its been a while and still no reply.
Is there anyone who can help me out with this problem???
Please.
Thanks.
joblo
(Joe)
December 15, 2011, 6:03pm
3
Only an idea, I didn’t test it.
Did you try jquery-cascade?
jonghwa
(Nasiajai)
December 15, 2011, 6:04pm
4
Hi,
Where are the key, values are from?
If they are coded at Model, you may follow this:
Model
class Member extends CActiveRecord
{
const GENDER_MALE=1;
const GENDER_FEMALE=2;
public function getGenderOptions()
{
return array(
self::GENDER_MALE=>'남자',
self::GENDER_FEMALE=>'여자',
);
}
public function getGenderText()
{
$genderOptions=$this->genderOptions;
return isset($genderOptions[$this->gender]) ? $genderOptions[$this->gender] : "unknown ({$this->gender})";
}
}
_form.php
<div class="row">
<?php echo $form->labelEx($model,'gender'); ?>
<?php echo $form->dropDownList($model,'gender',$model->getGenderOptions()); ?>
<?php echo $form->error($model,'gender'); ?>
</div>
view.php
array(
'name'=>'gender',
'value'=>CHtml::encode($model->getGenderText()),
),
_view.php
<b><?php echo CHtml::encode($data->getAttributeLabel('gender')); ?>:</b>
<?php echo CHtml::encode($data->getGenderText()); ?>
<br />
If you need the key/value from another table, refer the book Agile Web Application Development with Yii 1.1 and PHP5. It helped me.