alexandrieb Posted July 31, 2017 Share Posted July 31, 2017 (edited) Bonjour, Je développe un module et j'aimerais savoir comme ajouter un filtre dans le HelpForm pour forcer un format de fichier array( 'type' => 'file', 'label' => $this->l('Image 1'), 'name' => 'uploadedfile1', 'id' => 'uploadedfile1', 'required' => true, 'desc' => $this->l('Set the image (GIF)'), 'accept' => 'image/gif' ), Mais le accept ne semble pas fonctionner.Avez-vous une idée? Edited August 11, 2017 by alexandrieb (see edit history) Link to comment Share on other sites More sharing options...
BeComWeb Posted July 31, 2017 Share Posted July 31, 2017 Bonjour, Regarde comment c'est géré dans les modules blockadvertising et blockreinsurance. Vraisemblablement c'est la méthode ImageManager::validateUpload() qui se charge de ça Link to comment Share on other sites More sharing options...
alexandrieb Posted August 1, 2017 Author Share Posted August 1, 2017 Merci, dommage qu'on sait pas directement mettre cela dans le help form, ca aurait été plus cohérent.. car ici, pas vraiment de filtre, il compare au moment de la sauvegarde Link to comment Share on other sites More sharing options...
Matt75 Posted August 1, 2017 Share Posted August 1, 2017 (edited) Salut, Tu peux utiliser l'override du tpl du helper form dans ton module pour ajouter la fonctionnalité Si tu affiches ton helper form dans la méthode getContent() de ton module, tu dois placer ton fichier là : modules/MODULE_NAME/views/templates/admin/_configure/helpers/form/form.tpl Si tu utilises un controller dans ton module : modules/MODULE_NAME/views/templates/admin/CONTROLLER_NAME/helpers/form/form.tpl Pour CONTROLLER_NAME, Prestashop utilise Tools::toUnderscoreCase(substr($this->controller_name, 5)) pour déterminer sa valeur. Exemple de fichier tpl pour l'override : {extends file="helpers/form/form.tpl"} {block name="input"} {if $input.type == 'file'} // Ton code perso {else} {$smarty.block.parent} {/if} {/block} A+ Edited August 1, 2017 by Matt75 (see edit history) Link to comment Share on other sites More sharing options...
alexandrieb Posted August 1, 2017 Author Share Posted August 1, 2017 Merci pour la piste. En fait, je voulais ajouter un filtre aux input file mais apparemment c'est pas un simple <input type=file... Link to comment Share on other sites More sharing options...
alexandrieb Posted August 10, 2017 Author Share Posted August 10, 2017 Bonjour, j'ai tenté de placé mon fichier form.tpl dans modules/MODULE_NAME/views/templates/admin/_configure/helpers/form/form.tpl Mais il ne semble pas le prendre en compte Pourtant mon fichier est bien dans le getContent Dans mon getContent j'ai ceci $this->_html .= $this->renderForm(); Et dans mon renderForm j'ai bien array( 'type' => 'number', 'label' => $this->l('Maximum size'), 'desc' => $this->l('Test'), 'name' => 'SIZE', 'required' => true, 'min' => 10, 'max' => 90 ), Mon module n'a pas de controller... As-tu une idée? Link to comment Share on other sites More sharing options...
Matt75 Posted August 11, 2017 Share Posted August 11, 2017 Salut, Lorsque tu créé ton helper form, n'aurais-tu pas oublié de passer ton module au helper ? $helper->module = $this; A+ Link to comment Share on other sites More sharing options...
alexandrieb Posted August 11, 2017 Author Share Posted August 11, 2017 Merci, c'était bien ca 1 Link to comment Share on other sites More sharing options...
keberin Posted January 18, 2018 Share Posted January 18, 2018 Bonjour j'ai le même problème. Je n'utilise pas de controller et j'ai bien mis $helper->module = $this; Avez vous une idée de ce qui peut manquer? On 11/08/2017 at 10:29 AM, Matt75 said: Salut, Lorsque tu créé ton helper form, n'aurais-tu pas oublié de passer ton module au helper ? $helper->module = $this; A+ Link to comment Share on other sites More sharing options...
Matt75 Posted January 18, 2018 Share Posted January 18, 2018 Salut, Avec ton code sous les yeux, se serait plus pratique pour te dire ce qui peut manquer comme tu dis A+ Link to comment Share on other sites More sharing options...
keberin Posted January 18, 2018 Share Posted January 18, 2018 Bonjour Oui c'est sûr que ça sera plus facile Voila mon code getContent public function getContent() { $this->processConfiguration(); $html_confirmation_message=$this->display(__FILE__,'confirmationMessage.tpl'); $html_form=$this->renderForm(); return $html_confirmation_message.$html_form; } renderForm public function renderForm() { $this->context->controller->addCSS($this->_path.'views/css/font/flaticon.css',all); $fields_form= array( 'form'=> array( 'legend'=> array( 'title'=> $this->l('Buton top Module configuration'), 'icon'=>'icon-enveloppe' ), 'input'=> array( array( 'type' => 'color', 'label' => $this->l('Background color of the button'), 'name' => 'color', 'hint' => $this->l('Status will be highlighted in this color. HTML colors only.').' "lightblue", "#CC6600")' ), array( 'type' => 'color', 'label' => $this->l('Police color of the button'), 'name' => 'policeColor', 'hint' => $this->l('Status will be highlighted in this color. HTML colors only.').' "lightblue", "#CC6600")' ), array( 'type'=>'radio', 'label'=>$this->l('Button shape'), 'name'=>'shape', 'required'=> true, 'values' => array( array( 'id'=>'carre', 'value'=>'carre', 'label'=> $this->l('Square') ), array( 'id'=>'round', 'value'=>'rond', 'label'=> $this->l('Round') ) ), ), array( 'type'=>'radio', 'label'=>$this->l('Icon'), 'name'=>'icon', 'required'=> true, 'values' => array( array( 'id'=>'flaticon-arrows-8', 'value'=>'flaticon-arrows-8', 'label' => $this->l('flaticon-arrows-8'), 'icon' => 'flaticon-arrows-8' ), array( 'id'=>'flaticon-arrows-9', 'value'=>'flaticon-arrows-9', 'label'=> $this->l('flaticon-arrows-9'), 'icon' => 'flaticon-arrows-9' ) ), ), array( 'type'=>'text', 'label'=>$this->l('Text'), 'name'=>'message' ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ), ); $helper= new HelperForm(); $helper->table=$this->table; $helper->module = $this; $helper->default_form_language = $this->context->language->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0); $helper->identifier = $this->identifier; $helper->submit_action='submit_buttontop_form'; $helper->currentIndex=AdminController::$currentIndex.'&configure='.$this->name; $helper->token=Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars= array( 'fields_value'=>array( 'message'=>Tools::getValue('message',Configuration::get('BUTTONTOP_MESSAGE')), 'shape'=>Tools::getValue('shape',Configuration::get('BUTTONTOP_SHAPE')), 'color'=>Tools::getValue('color',Configuration::get('BUTTONTOP_COLOR')), 'policeColor'=>Tools::getValue('policeColor',Configuration::get('BUTTONTOP_POLICECOLOR')), 'icon'=>Tools::getValue('icon',Configuration::get('BUTTONTOP_ICON')), ), 'languages'=>$this->context->controller->getLanguages() ); return $helper->generateForm(array($fields_form)); } et form.tpl {extends file="helpers/form/form.tpl"} {block name="input"} {if $input.name == 'icon'} <div class="col-lg-9"> {foreach $input.values as $value} <div class="radio {if isset($input.class)}{$input.class|escape:'htmlall':'UTF-8'}{/if}"> {strip} <label> <input type="radio" name="{$input.name|escape:'htmlall':'UTF-8'}" id="{$value.id|escape:'htmlall':'UTF-8'}" value="{$value.value|escape:'html':'UTF-8'}"{if $fields_value[$input.name] == $value.value} checked="checked"{/if}{if isset($input.disabled) && $input.disabled} disabled="disabled"{/if}/> <i width="50px" height="50px" class="{$value.icon|escape:'htmlall':'UTF-8'}" alt=""></i> {$value.label|escape:'htmlall':'UTF-8'} </label> {/strip} </div> {if isset($value.p) && $value.p}<p class="help-block">{$value.p|escape:'htmlall':'UTF-8'}</p>{/if} {/foreach} </div> {else} {$smarty.block.parent} {/if} {/block} Merci d'avance Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now