Jump to content

2 forms on the same module


Recommended Posts

Hi,

 

I've created back-office module with a form.

 

I want to create a second form on the same configuration page of my module but I don't know how to do that.

 

I'm on PS 1.6.

 

Do you have any solution ?

 

Thanks :)

Link to comment
Share on other sites

Hi,

 

I've created back-office module with a form.

 

I want to create a second form on the same configuration page of my module but I don't know how to do that.

 

I'm on PS 1.6.

 

Do you have any solution ?

 

Thanks :)

Hi..

 

see this demo create a multiple form same configuration page

 

public function renderForm()
{


$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('text'),
'name' => 'text',
),
array(
'type' => 'text',
'label' => $this->l('text2'),
'name' => 'text2',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm1',
)
),
);


$fields_form_2 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'textarea',
'autoload_rte' => true,
'label' => $this->l('textarea'),
'name' => 'textarea',
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm2',
)
),
);


$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table =  $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitModule';
$helper->module = $this;
$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(
'currencies' => Currency::getCurrencies(),
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);


return $helper->generateForm(array($fields_form_1, $fields_form_2));
}

Thanks

Link to comment
Share on other sites

 

Hi..

 

see this demo create a multiple form same configuration page

 

public function renderForm()
{


$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('text'),
'name' => 'text',
),
array(
'type' => 'text',
'label' => $this->l('text2'),
'name' => 'text2',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm1',
)
),
);


$fields_form_2 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'textarea',
'autoload_rte' => true,
'label' => $this->l('textarea'),
'name' => 'textarea',
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm2',
)
),
);


$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table =  $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitModule';
$helper->module = $this;
$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(
'currencies' => Currency::getCurrencies(),
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);


return $helper->generateForm(array($fields_form_1, $fields_form_2));
}

Thanks

 

Okay.

 

So, I can delete getConfigForm() function ?

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

  • 1 year later...


 

Quote

public function renderForm()
{


$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('text'),
'name' => 'text',
),
array(
'type' => 'text',
'label' => $this->l('text2'),
'name' => 'text2',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm1',
)
),
);


$fields_form_2 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'textarea',
'autoload_rte' => true,
'label' => $this->l('textarea'),
'name' => 'textarea',
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm2',
)
),
);


$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table =  $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitModule';
$helper->module = $this;
$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(
'currencies' => Currency::getCurrencies(),
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);


return $helper->generateForm(array($fields_form_1, $fields_form_2));

[2] htmlspecialchars() expects parameter 1 to be string, array given 

I have 2 warrming!!! why ?

Link to comment
Share on other sites

On 6/6/2017 at 11:01 AM, Nishith said:

Hi..

 

see this demo create a multiple form same configuration page

 


public function renderForm()
{


$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('text'),
'name' => 'text',
),
array(
'type' => 'text',
'label' => $this->l('text2'),
'name' => 'text2',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm1',
)
),
);


$fields_form_2 = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'textarea',
'autoload_rte' => true,
'label' => $this->l('textarea'),
'name' => 'textarea',
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
'name' => 'submitForm2',
)
),
);


$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table =  $this->table;
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper->default_form_language = $lang->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitModule';
$helper->module = $this;
$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(
'currencies' => Currency::getCurrencies(),
'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);


return $helper->generateForm(array($fields_form_1, $fields_form_2));
}

Thanks

[2] htmlspecialchars() expects parameter 1 to be string, array given 

I have 2 warrming!!! why ?

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...