如何在 PRESTASHOP 1.6.3 中使用 HelperForm 类时向用户未公开的字段(例如 date_add 和 date_upd)添加隐藏值或插入值
我创建了一个新模块,现在我的表中有两个字段需要在发生新添加和用户完成更新时插入,但是当我在 PRESTASHOP 中使用 HelperForm 类时如何执行此操作
下面是我的渲染表单脚本
// This form is populated when add or edit is clicked
public function renderForm()
{
$years = Tools::dateYears();
$months = Tools::dateMonths();
$days = Tools::dateDays();
$ticketSeries = Winners::getTicketSeries();
$prdtCategory = Winners::getProductCategory();
$nationality = Winners::getNationality();
$this->fields_form = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Configure your Winner'),
'icon' => 'icon-user'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name'),
'name' => 'name',
'required' => true,
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:'
),
array(
'type' => 'text',
'label' => $this->l('Ticket No'),
'name' => 'ticket_no',
'required' => true,
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:'
),
array(
'type' => 'select',
'label' => $this->l('Ticket Series'),
'name' => 'series',
'required' => true,
'options' => array(
'query' => $ticketSeries,
'id' => 'ticket_series_name',
'name' => 'ticket_series_name'
),
'col' => '4',
'hint' => array(
$this->l('The ticket series of each draw !!.')
)
),
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true,
'options' => array(
'query' => $prdtCategory,
'id' => 'name',
'name' => 'name'
),
'col' => '4',
'hint' => array(
$this->l('Product Category.')
)
),
array(
'type' => 'date',
'label' => $this->l('Draw Date:'),
'name' => 'draw_date',
'size' => 10,
'required' => true,
'desc' => $this->l('The draw date of this series'),
),
array(
'type' => 'select',
'label' => $this->l('Nationality'),
'name' => 'nationality',
'required' => true,
'options' => array(
'query' => $nationality,
'id' => 'name',
'name' => 'name'
),
'col' => '4',
'hint' => array(
$this->l('Nationality the winner Belongs .')
)
),
array(
'type' => 'textarea',
'label' => $this->l('Testimonial'),
'name' => 'testimonial',
'required' => true,
'autoload_rte' => true,
'rows' => 7,
'cols' => 40,
'hint' => $this->l('Invalid characters:').' <>;=#{}'
), // add tag 'autoload_rte' => true, 'lang' => true, --> lang i removed
// since the editor value did not submit editor
)
);
//d(Tools::getIsset('update'));
if (Tools::getIsset('add') )
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Add Date'),
'name' => 'date_add',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:'
))
));
if (Tools::getIsset('update'))
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Update Date'),
'name' => 'date_upd',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;? =+()@#"°{}_$%:'
))
));
$this->fields_form['submit'] = array(
'title' => $this->l('Save'),
);
$this->addJqueryUI('ui.datepicker');
return parent::renderForm();
}
我尝试了类似下面的东西但没有用
if (Tools::getIsset('add') )
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Add Date'),
'name' => 'date_add',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;?=+()@#"°{}_$%:'
))
));
if (Tools::getIsset('update'))
$this->fields_form = array_merge(array(
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Update Date'),
'name' => 'date_upd',
'col' => '4',
'hint' => $this->l('Invalid characters:').' 0-9!<>,;? =+()@#"°{}_$%:'
))
));