Hi…
hello, I would like to know how to fill two TBSelect 2 courses when I enter the update method. I have a rural town and a state field and want to fill them with the registry data that clicked, so I can edit their values.
Could someone help me? I’m starting my studies with yii.
Thank U.
<div class="row-fluid" style="margin-bottom: 10px;">
<?php
$this->widget(
'booster.widgets.TbSelect2',
array(
'asDropDownList' => true,
'name' => 'estado',
'data' => CHtml::listData(estado::model()->findAll(), 'id_estado', 'uf'),
'model' => 'estado',
'options' => array(
'placeholder' => 'Estado (UF)',
'width' => '5%'
),
'htmlOptions' => array('onChange'=>'js:
var url = \'' . CController::createUrl('/cidade/findCidadeByEstado') . '\';
$.ajax({
type: "POST",
url: url,
data: $(\'#estado\')
}).done(function(data){ $(\'#agencia_bancaria_id_cidade\').html(data); });',
)
)
);
?>
</div>
<div class="row-fluid" style="margin-bottom: 10px;">
<?php
$this->widget(
'booster.widgets.TbSelect2',
array(
'asDropDownList' => true,
'name' => 'agencia_bancaria[id_cidade]',
'data' => '',
'model' => 'cidade',
'options' => array(
'placeholder' => 'Selecione o Estado',
'width' => '15%',
),
'htmlOptions' => array('options' => array(
'active' => array('selected' => $model->attributes['id_cidade'])
)
)
)
);
?>
</div>