Jump to content

Prestashop 1.6 - champ checkbox personnalisé produit


Recommended Posts

Bonjour,
J’ai suivi ce tuto : ici

Pour pouvoir rajouter des champs pour les produits, pas de soucis pour des champs texte.

Par contre, j’ai besoin de 2 champs de type Booléen. J’ai donc modifié les fichiers de la façon suivante :
Fichier Product.php :

class Product extends ProductCore
{
public $produitsregionaux;
public $abbio;
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
Product::$definition[‘fields’][‘produitsregionaux’] = array(‘type’ => self::TYPE_BOOL, ‘shop’ => true, ‘validate’ => ‘isBool’);
Product::$definition[‘fields’][‘abbio’] = array(‘type’ => self::TYPE_BOOL, ‘shop’ => true, ‘validate’ => ‘isBool’);
parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
}
}

Fichier informations.tpl :

 
<div class="form-group">
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="produitsregionaux" type="radio" onclick=""}</span></div>
<label class="control-label col-lg-2">
Produits régionaux
</label>
<div class="col-lg-9">
<span class="switch prestashop-switch fixed-width-lg">
<input onclick="toggleDraftWarning(false);showOptions(true);showRedirectProductOptions(false);" type="radio" name="produitsregionaux" id="produitsregionaux_on" value="1" {if $product->produitsregionaux}checked="checked" {/if} />
<label for="produitsregionaux_on" class="radioCheck">
{l s='Yes'}
</label>
<input onclick="toggleDraftWarning(true);showOptions(false);showRedirectProductOptions(true);"  type="radio" name="produitsregionaux" id="produitsregionaux_off" value="0" {if !$product->produitsregionaux}checked="checked"{/if} />
<label for="produitsregionaux_off" class="radioCheck">
{l s='No'}
</label>
<a class="slide-button btn"></a>
</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="abbio" type="radio" onclick=""}</span></div>
<label class="control-label col-lg-2">
AB Bio{$product->abbio}
</label>
<div class="col-lg-9">
<span class="switch prestashop-switch fixed-width-lg">
<input onclick="toggleDraftWarning(false);showOptions(true);showRedirectProductOptions(false);" type="radio" name="abbio" id="abbio_on" value="1" {if $product->abbio}checked="checked" {/if} />
<label for="abbio_on" class="radioCheck">
{l s='Yes'}
</label>
<input onclick="toggleDraftWarning(true);showOptions(false);showRedirectProductOptions(true);"  type="radio" name="abbio" id="abbio_off" value="0" {if !$product->abbio}checked="checked"{/if} />
<label for="abbio_off" class="radioCheck">
{l s='No'}
</label>
<a class="slide-button btn"></a>
</span>
</div>
</div>

Lorsque je clique sur « enregistrer », les données ne sont pas enregistrées.
D’avance merci

Edited by taka10 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...