加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – prestashop show helper form复选框已选中

发布时间:2020-12-13 17:31:13 所属栏目:PHP教程 来源:网络整理
导读:在Prestashop模块中,我想显示一个复选框.为此我只是采取了这样的辅助类方法 $display_settings = array( 'form' = array( 'legend' = array( 'title' = $this-l( 'Display Settings' ),'icon' = 'icon-cogs' ),'input' = array( array( 'type' = 'checkbox',
在Prestashop模块中,我想显示一个复选框.为此我只是采取了这样的辅助类方法

$display_settings = array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l( 'Display Settings' ),'icon' => 'icon-cogs'
                ),'input' => array(
                array(
                    'type' => 'checkbox','name' => 'display','values' => array(
                        'query' => array(
                            array(
                                'id' => 'show_header','name' => $this->l('show header'),'val' => '1','checked' => 'checked'
                            ),),'id' => 'id','name' => 'name'
                    )
                ),'submit' => array(
                    'title' => $this->l( 'Save Display Settings' ),'class' => 'button pull-right','name' => 'save-main-display-settings',)
            ),);

但是这个只显示了checkbow(未选中).我试图将val变成0,1.但它对我没有用.那么有人可以告诉我如何在帮助程序类中选中复选框.任何帮助或建议都将非常适合.谢谢

解决方法

请删除’checked’=> “检查”没有必要.其余的代码是可以的 – 但它只是FORM结构定义,如果你想用数据填充它(选中复选框是数据定义而不是结构)你需要向HelperForm提供数据.

要选中复选框,请将其设置为:

$helper = new HelperForm();
$helper->fields_value['display_show_header'] = true;

名称“display_show_header”是您的名称“display”和“show_header”的串联,您还可以在查看渲染复选框时在firebug中看到此名称.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读