back again to this forum.. start asking all yii2 lesson i am using _form for create and update.. i use event onchange to call another table that has relation name in create form.. the problem is when i use this form to update, a couple field still blank because there is no triggers event change. here is my form code
<?php $idnpwp = ArrayHelper::map(Mfwp::find()->all(),"id", "npwp");?>
<?= $form->field($model, 'id_sm_wp')->widget(Select2::classname(), [
'language' => 'id',
'data' => $idnpwp,
'options' => ['placeholder' => 'Select a NPWP ...'],
'pluginOptions' => [
'allowClear' => true
],
'pluginEvents' => [
'change'=>'function(event){
var data_id = event.currentTarget.value;
$.post("'.Url::to(['mfwp/lists']).'?id="+data_id,function(data){
$("input#namas").val(data.nama_wp);$("#alamats").val(data.alamat_wp);
$("input#nips").val(data.nip_pendek);
$("input#namaar").val(data.pejabat.nama)
});
}'
]
]);
?>
<?php if ($this->action->id == "update"){
//what code should be
}
?>
<label> Nama Wajib Pajak </label>
<?= Html::textInput('nama','', $options=['id' => 'namas','class'=>'form-
control', 'style'=>'width:1140px;margin-left:0px']) ?>
<br>
<label> Alamat Wajib Pajak </label>
<?= Html::textArea('alamat','', $options=['id' => 'alamats','class'=>'form-
control', 'style'=>'width:1140px;margin-left:0px']) ?>
<br>
<table >
<tr>
<th>
<label> NIP </label>
<?= Html::input('text','nip','', $options=['id' =>
'nips','class'=>'form-control', 'style'=>'width:200px;margin-
left:0px']) ?>
</th>
<th>
<label style='margin-left:100px'> Nama Account Representative
</label>
<?= Html::input('text','nama','', $options=['id' =>
'namaar','class'=>'form-control',
'style'=>'width:840px;margin-left:100px']) ?>
</th>
</tr>
</table>
<br>
anyone has reference should i read to deal with this case..thx a lot