I've set certain fields to be disabled when a checkbox is checked. But when a user submits the form data and it's invalid, page is reloaded, where the checkbox remains checked but the fields are no longer disabled. Not sure how I can fix this?
The javascript:
$('#CommentFrequencyOk').on('click', function () {
$('#test').prop('disabled', this.checked);
});
The fields to be disabled:
<fieldset id="test">
<?php echo $this->Form->input('frequency_remarks'); ?>
<?php echo $this->Form->input('duration_remarks'); ?>
</fieldset>
And the checkbox:
<div class="checkbox">
<label for="CommentFrequencyOk">
<input type="hidden" name="data[Comment][frequency_ok]" id="CommentFrequencyOk_" value="0" />
<input type="checkbox" name="data[Comment][frequency_ok]" class="checkbox" value="1" id="CommentFrequencyOk" /> Frequency
</label>
</div>