ikn Posted November 22, 2013 Share Posted November 22, 2013 Hi, I’m trying to write my first prestashop module. I follow “Creating a PrestaShop module” tutorial and everything goes fine until I added 'lang' => true in configuration form field. This produce disappear of that particular field. Link to comment Share on other sites More sharing options...
vekia Posted November 24, 2013 Share Posted November 24, 2013 can you show your code please? it will be much easier to say what's going on there Link to comment Share on other sites More sharing options...
ikn Posted November 25, 2013 Author Share Posted November 25, 2013 thi is my module code if (!defined('_PS_VERSION_')) exit; class FaqExtra extends Module{ public function __construct() { $this->name = 'faqextra'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'Ivan Neykov'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('FAQ Extra'); $this->description = $this->l('Adds a block with Frequently Asked Questions.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('FAQEXTRA_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); return parent::install() && $this->registerHook('leftColumn') && $this->registerHook('rightColumn') && Configuration::updateValue('FAQEXTRA_NAME', 'FAQ'); } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('FAQEXTRA_NAME')) return false; return true; } public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'faq_module_name' => Configuration::get('FAQEXTRA_NAME'), 'faq_module_link' => $this->context->link->getModuleLink('faqextra', 'display') ) ); return $this->display(__FILE__, 'faqextra.tpl'); } public function hookDisplayRightColumn($params) { return $this->hookDisplayLeftColumn($params); } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('FAQEXTRA_NAME')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError( $this->l('Invalid Configuration value') ); else { Configuration::updateValue('FAQEXTRA_NAME', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default Language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings') ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value'), 'name' => 'FAQEXTRA_NAME', 'size' => 20, 'lang' => true, 'required' => true ) ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $helper = new HelperForm(); // Module, t oken and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['FAQEXTRA_NAME'] = Configuration::get('FAQEXTRA_NAME'); return $helper->generateForm($fields_form); }} and this is part of produced html <label>Configuration value </label> <div class="margin-form"> <div class="translatable"> </div> <sup>*</sup> </div> <div class="clear"></div> ...... 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