I have a form and a need to change the checkbox to checked or unchecked based int selection of the dropDownList. I am a begner in PHP and Yii2 here my form
<div class="npi-approval-review-form">
<?php if(!empty(Yii::$app->session->get('activity') && Yii::$app->session->get('activity')->need_signature == 'S'))$model->sign = 1; ?><?php ?>
<?php $form = ActiveForm::begin(); ?>
<table>
<tbody>
<tr>
<td>
<?php if ($model->type == TypeOrigin::Aprovação): ?>
<?= $form->field($model, 'status')->dropDownList(StatusReview::asArray(), ['prompt'=>StatusApproval::asArray()[$model->status]]); ?>
<?php endif; ?>
<?php if ($model->type == TypeOrigin::Revisão): ?>
<?= $form->field($model, 'status')->dropDownList(StatusReview::asArray(), ['prompt'=>StatusReview::asArray()[$model->status]]); ?>
<?php endif; ?>
</td>
<td> </td>
<td>
<?= $form->field($model, 'type')->textInput(['value'=>TypeOrigin::asArray()[$model->type]
, 'readonly' => true, 'disabled' => 'true']);?>
</td>
</tr>
</tbody>
</table>
<?= $form->field($model, 'conclusion')->textarea(['rows' => 5, 'maxlength' => true]) ?>
<?= $form->field($model, 'sign')->checkBox(['value'=> $model->status == '2' ? '0' : '1']) ?>
<div class="form-group">
<?= Html::submitButton('Salvar', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
Aucun commentaire:
Enregistrer un commentaire