Page 1 of 1

Checkbox Help Please!

Posted: Mon Jun 20, 2016 7:45 am
by stutzy
Hi all, I'm hoping someone can help me. I'm trying to build a simple module, with a checkbox, that when ticked shows an image at the front end.

The value should be stored, and the checkbox stays the way it was saved, but this is not happening for some reason.

admin/controller:

Code: Select all

if (isset($this->request->post['show_img'])) {
$data['show_img'] = $this->request->post['show_img'];
} else {
$data['show_img'] = $this->config->get('show_img');
}
And in the template file:

Code: Select all

<?php if ($show_img) { ?>
<label><input type="checkbox" name="show_img" value="1" checked="checked" /></label>
<?php } else { ?>
<label><input type="checkbox" name="show_img" value="1" /></label>
<?php } ?>
I have read and tried the solutions in this post Module checkbox driving me nuts! [SOLVED] but none of this works either, even when i try using radio buttons with a simple yes/no it still does not store the value when save.

Am i missing something??? Please, please help, I'm going crazy :crazy: