Skip to content

Instantly share code, notes, and snippets.

@AliShareei
Created December 4, 2017 12:01
Show Gist options
  • Save AliShareei/af6c3ff682643965adabb27f94c0a47c to your computer and use it in GitHub Desktop.
Save AliShareei/af6c3ff682643965adabb27f94c0a47c to your computer and use it in GitHub Desktop.
example form
public function getContent()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->trans('Settings', array(), 'Admin.Global'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'swap',
'label' => $this->l('swap 1'),
'name' => 'swap_1',
'size' => 12,
'options' => array(
'query' => $this->getSampleList(),
'id' => 'id',
'name' => 'name'
),
'required' => TRUE,
),
array(
'type' => 'swap',
'label' => $this->l('swap 2'),
'name' => 'swap_2',
'size' => 12,
'options' => array(
'query' => $this->getSampleList(),
'id' => 'id',
'name' => 'name'
),
'required' => TRUE,
),
),
'submit' => array(
'title' => $this->trans('Save', array(), 'Admin.Actions')
)
),
);
$lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->default_form_language = $lang->id;
$helper->module = $this;
$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 = 'submitStoreConf';
$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(
'uri' => $this->getPathUri(),
//'fields_value' => $this->getConfigFieldsValues(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm(array($fields_form));
}
public function getSampleList()
{
return array(
array('id' => 'one','name' => 'one'),
array('id' => 'two','name' => 'two'),
array('id' => 'three','name' => 'three'),
array('id' => 'four','name' => 'four'),
array('id' => 'five','name' => 'five'),
array('id' => 'six','name' => 'six'),
array('id' => 'seven','name' => 'seven'),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment