8.4.2 How to handle checkbox in single page controller?
Permalink
I have a checkbox in a single page:
I set its value with JS:
but the controller doesn't read its value.
I tried both of these:
The first one reads nothing, the second one always reads 0.
I know the save() function reads checkbox values but I don't save anything, my single page controller simply needs to check the form inputs and then route to another page.
How can I handle the checkbox in a single page controller without saving?
I set its value with JS:
$('#policy').on('change', function() { $(this).val(this.checked ? 1 : 0); $(this).attr('checked', this.checked ? true : false); }).trigger('change');
but the controller doesn't read its value.
I tried both of these:
$data = $this->post(); $policy = $data['policy']; $policy = isset($data['policy']) ? 1 : 0;
The first one reads nothing, the second one always reads 0.
I know the save() function reads checkbox values but I don't save anything, my single page controller simply needs to check the form inputs and then route to another page.
How can I handle the checkbox in a single page controller without saving?
All is working fine actually