【问题标题】:Display same form data in the input text fields even after form submission即使在表单提交后,在输入文本字段中显示相同的表单数据
【发布时间】:2017-02-23 13:00:23
【问题描述】:
$fields_form = array(
        'form' => array(
            'legend' => array(
                'title' => $this->l('Configure Settings'),
                'icon' => 'icon-cogs'
            ),
            'description' => $form_desc,
        'input' => array(
            array(
              'type'     => 'text',
              'label'    => $this->l('textfield1'),
              'name'     => 'username',
              'size'     => 50,
              'class' => 'fixed-width-xxl',
              'required' => true
          ),
            array(
              'type'     => 'password',
              'label'    => $this->l('textfield2'),
              'name'     => 'password',
              'size'     => 50,
              'class' => 'fixed-width-xl',
              'required' => true,
          ),
            ),
          'submit' => array(
              'name' => 'submitconfigureoptions',
              'title' => $this->l('Save'),
              'icon' => 'process-icon-save',
              'class' => 'btn btn-default pull-right'

          ),
        )
    );

我有一个包含四个输入文本字段和一个提交按钮的表单。因此,提交表单后,我在输入文本字段中输入的相同值必须在页面刷新后显示在表单中。

【问题讨论】:

  • 在这种情况下,您可以将字段保存在本地存储中并可以显示。如果您能提供您的代码,将会很有帮助。

标签: forms prestashop-1.7


【解决方案1】:

要在 Helper Form 中保留值,您可以使用以下代码:

$helper->fields_value['field_name'] = 'field_value';

在 generateForm() 函数之前添加此代码,这将在页面加载之前将值添加到您的字段中。

【讨论】:

    猜你喜欢
    • 2021-09-01
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 2020-03-15
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多