zuppa Posted October 17, 2023 Share Posted October 17, 2023 Hello, I'm trying to implement a form in my controller, here's the code: public function formProduto() { $helper = new HelperForm(); $form = array( 'legend' => array( 'title' => $this->l('Product Information'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Product Name'), 'name' => 'product_name', ), array( 'type' => 'select', 'label' => $this->l('Category'), 'name' => 'category_id', 'options' => array( 'query' => $this->categoryOptions(), // Replace with your category options 'id' => 'id', 'name' => 'name', ), ), array( 'type' => 'select', 'label' => $this->l('Supports'), 'name' => 'support_ids[]', // Use an array for multiple selection 'options' => array( 'query' => $this->supportOptions(), // Replace with your support options 'id' => 'id_support', 'name' => 'name', ), 'multiple' => true, // Enable multiple selection ), array( 'type' => 'file', 'label' => $this->l('Product Image'), 'name' => 'product_image', ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', ), ); $helper->fields_value = array( 'product_name' => 'Default Product Name', // Set default values if needed 'category_id' => 1, // Set the default category ID 'support_ids[]' => array(1, 2), // Set default support IDs as an array 'product_image' => 'DefaultImage.jpg', // Set the default image file name ); $helper->form = $form; return $helper->generateForm($form); } and its throwing Warning: Undefined array key "form" : $_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['fieldset']->value['form'], 'field', false, 'key'); I'm new to prestashop system, what I'm I missing? 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