在prestashop 1.7中显示表单文本字段中的配置值

在prestashop 1.7中显示表单文本字段中的配置值

问题描述:

I am creating a module in prestashop 1.7 to save my settings.

Also I created a form to display my settings. Form sample is shown below:-

//display form function

public function renderCustomerForm()
{
    $this->fields_form = array(
        'legend' => array(
            'title' => $this->l('Customer  Settings'),
            'icon' => 'icon-time'
            ),
        'input'=>array(
            array(
                'type' => 'text',
                'label' => $this->l('BusinessCustomerFlag'),
                'name' => 'C_BUSINESS_FLAG',
                'lang' => false,
                'required' => true
                ),      

            ),
        'submit' => array(
            'title' => $this->l('Save'),           
            'name' => 'submitCustomer',            
            'icon' => 'process-icon-save'  
            )
        );

I am saving this values in configuration table using configuration class functions.

I know how to retrieve it but don't know how to show in the form. Please some one guide on this will be really helpful.

我在prestashop 1.7中创建一个模块来保存我的设置。 p>

我还创建了一个表单来显示我的设置。 表单示例如下所示: - p>

  //显示表单函数
 
公共函数renderCustomerForm()
 {
 $ this-> fields_form = array(
  'legend'=>数组(
'标题'=> $ this-> l('客户设置'),
'图标'=>'icon-time'
),
'输入 '=>数组(
数组(
'类型'=>'文字',
'标签'=> $ this-> l('BusinessCustomerFlag'),
'name'=>  'C_BUSINESS_FLAG',
'lang'=> false,
'required'=> true 
),
 
),
'submit'=> array(
'title'=>  ; $ this-> l('保存'),
'名称'=>'submitCustomer',
'icon'=>'process-icon-save'
)
); 
   pre> 
 
 

我使用配置类函数在配置表中保存这些值。 p>

我知道如何检索它但不知道如何 在表格中显示。 请一些关于此的指南真的很有帮助。 p> div>

Add this line to helper on your module (before generateForm):

$helper->fields_value = $this->getFormValues();

and add function to define values:

public function getFormValues()
{
    $fields_value = array();
    $fields_value['C_BUSINESS_FLAG'] = "some data or retrieved data";

    return $fields_value;
}