Hi there,
I'm having a bit of a problem with creating new check boxes on the Information tabs - The check boxes show and are ticked based on the database entry of 1, but when I try to untick, it doesn't save. Funnily enough, if the database has a 0, the checkbox is unticked, and will save if I tick it.
Can anyone help?
I have the following:
In the database (ps_product and ps_product_shop) i have:
custom_field1 - tinyint(1) - default(1)
custom_field2 - tinyint(1) - default(1)
In the informations.tpl:
<div class="checkbox">
<label for="custom_field1">
<input type="checkbox" name="custom_field1" id="custom_field1" value="1" {if $product->custom_field1}checked="checked"{/if} >
{l s='Custom Field 1'}
</label>
</div>
<div class="checkbox">
<label for="custom_field2">
<input type="checkbox" name="custom_field2" id="custom_field2" value="1" {if $product->custom_field2}checked="checked"{/if} >
{l s='Custom Field 2'}
</label>
</div>
In the product.php override:
public $custom_field1 = false;
public $custom_field2 = false;
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
self::$definition['fields']['custom_field1'] = array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool');
self::$definition['fields']['custom_field2'] = array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool');
parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
}
For some reason, this isn't working as described.
Can anyone help?
Thank you!