Beispiel #1
0
<div class="sysconfigmain-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'provcode')->dropDownList(ArrayHelper::map(Campur::find()->all(), 'changwatcode', 'changwatcode'), array('id' => 'provcode', 'onchange' => '$.post("index.php?r=sysconfigmain/listamp&provcode="+this.value,function(data){
                    $("#ampurcodefull").html(data);
                     $("#sysconfigmain-distcode").val(data.substring(3,4));
                });'));
?>


    <?php 
echo $form->field($model, 'district_code')->dropDownList(ArrayHelper::map(Campur::find()->where(['changwatcode' => $model->provcode])->all(), 'ampurcodefull', 'ampurname'), array('id' => 'ampurcodefull', 'prompt' => '--อำเภอ--'));
?>
    <?php 
echo $form->field($model, 'note1')->textInput();
?>


    <?php 
echo $form->field($model, 'note2')->widget(\yii\jui\DatePicker::classname(), ['language' => 'th', 'dateFormat' => 'yyyy-MM-dd', 'clientOptions' => ['changeMonth' => true, 'changeYear' => true]]);
?>





    <div class="form-group">
 public function actionListamp($provcode)
 {
     $amp = Campur::find()->where(['changwatcode' => $provcode])->all();
     foreach ($amp as $a) {
         echo "<option value='{$a->ampurcodefull}'>{$a->ampurname}</option>";
     }
 }