I have an ActiveForm in my _form view:
<?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'isInternal')->checkbox() ?> <?php ActiveForm::end(); ?>
('isInternal' is a boolean)
If the checkbox is selected I want to show another checkbox:
$form->field($model, 'activateReminder')->checkbox();
Is there a possibility? Maybe with JavaScript like this?
<?= $form->field($model, 'isInternal')->checkbox(['onclick' =>
'showInternDetails()']) ?>
<script>
function showInternDetails() {
$model->isInternal = 1;
}
</script>
<?php
if($model->isInternal == true)
{
$form->field($model, 'activateReminder')->checkbox();
}
?>
Aucun commentaire:
Enregistrer un commentaire