Rhobur Posted August 15, 2016 Share Posted August 15, 2016 Hi, Can someone see what I can't see? I have this code in a module. Nothing seems to be wrong, but I the form doesn't display, I get the error: Undefined variable: fields_form The code is bellow: public function renderForm(){ $this->fields_form = array( 'legend' => array( 'title' => $this->l('Configurare variabile API'), 'image' => '../modules/rca/images/logo_stores.png', ), 'input' => array( array( 'label' => $this->l('RCA user name'), 'type' => 'text', 'name' => 'rca_user_name' ), array( 'label' => $this->l('RCA password'), 'type' => 'text', 'name' => 'rca_password' ), array( 'label' => $this->l('URL token RCA'), 'type' => 'text', 'name' => 'url_token_rca', 'desc' => $this->l('URL to get the authentification token.') ), array( 'label' => $this->l('URL cotatie RCA'), 'type' => 'text', 'name' => 'url_quote_rca', 'desc' => $this->l('URL to get the RCA quote.') ), array( 'label' => $this->l('URL oferta RCA'), 'type' => 'text', 'name' => 'url_offer_rca', 'desc' => $this->l('URL to get the RCA offer.') ), array( 'label' => $this->l('URL comanda RCA'), 'type' => 'text', 'name' => 'url_order_rca', 'desc' => $this->l('URL to order the RCA.') ), array( 'label' => $this->l('Username evignettes'), 'type' => 'text', 'name' => 'user_name_rov' ), array( 'label' => $this->l('Authentification key Evignettes'), 'type' => 'text', 'name' => 'auth_key_rov', 'desc' => $this->l('Add the authentification key to access the evignettes API.') ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ); $helper = new HelperForm(); $helper->module = $this; $helper->table = 'rca'; $helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); $helper->allow_employee_form_lang = (int)Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG'); $helper->submit_action = 'rca_form'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => array( 'rca_user_name' => Tools::getValue('rca_user_name', Configuration::get('RCA_USER')), 'url_token_rca' => Tools::getValue('url_token_rca', Configuration::get('RCA_TOKEN')), 'url_quote_rca' => Tools::getValue('url_quote_rca', Configuration::get('RCA_QUOTE_URL')), 'url_offer_rca' => Tools::getValue('url_offer_rca', Configuration::get('RCA_OFFER_URL')), 'url_order_rca' => Tools::getValue('url_order_rca', Configuration::get('RCA_ORDER_URL')), 'user_name_rov' => Tools::getValue('user_name_rov', Configuration::get('ROV_USER')), 'auth_key_rov' => Tools::getValue('auth_key_rov', Configuration::get('ROV_KEY')) ), 'languages' => $this->context->controller->getLanguages() ); return $helper->generateForm(array($fields_form)); } Link to comment Share on other sites More sharing options...
El Patron Posted August 15, 2016 Share Posted August 15, 2016 use: $fields_form = array( 'form' => array( if you look at native modules you will find good examples on usage. I will say however that 'helper' is a funny name for something so cumbersome to use. Link to comment Share on other sites More sharing options...
Rhobur Posted August 15, 2016 Author Share Posted August 15, 2016 Thank you El Patron, you're a life saver! Care to explain what was this necessary? In the book and every example I found the $this->fields_form = array( was the default. Before asking here I even tried $fields_form[0]['form] with no luck. Link to comment Share on other sites More sharing options...
El Patron Posted August 15, 2016 Share Posted August 15, 2016 I typically will just search native for examples that I know work. I miss the days one could be forms with say dreamweaver or spry assets, building arrays to build a form is 'very' difficult....I don't know if ps developers have some WYSIWYG form builder that works with helper concept...honestly I roll my eyes every time I write/say helper...lol 1 Link to comment Share on other sites More sharing options...
vekia Posted August 15, 2016 Share Posted August 15, 2016 Undefined variable: fields_form return $helper->generateForm(array($fields_form)); variable $fields_form does not exist! you've got $this->fields_form instead Link to comment Share on other sites More sharing options...
Rhobur Posted August 15, 2016 Author Share Posted August 15, 2016 But I have tried with $fields_form instead of $this->fields_form and then I still got Undefined variable: form Link to comment Share on other sites More sharing options...
Rhobur Posted August 15, 2016 Author Share Posted August 15, 2016 still :puzzled: 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