doushi1960 2018-10-15 21:55
浏览 40

如何在PrestaShop 1.7表单中使用type switch来改变css

I want a type switch to change value in css class but type switch does not support custom values then 1 and 0? how to do it?

   'input' => array(
    'type' => 'switch',
    'label' => $this->l('backgrounds'),
    'name' => 'test',
    'options' => array(
    'query' => $test,
          'id' => 'id_option',
          'name' => 'name'
        )
    )
),

    $test = array(
        array(
            'id_option' => '#header {background: #ffffff;}',
            'name' => $this->l('white bg')
        ),
        array(
            'id_option' => '#header {background: #333333;}',
            'name' => $this->l('dark bg')
        ),
    );
  • 写回答

2条回答 默认 最新

  • dsour68888 2018-10-15 22:40
    关注

    For type 'switch' you have to use 'values' instead of 'options'.

    This is example from default PrestaShop module :

        $input = array(
            'type' => 'switch',
            'label' => $this->trans('Newsletter', array(), 'Admin.Orderscustomers.Feature'),
            'name' => 'newsletter',
            'required' => false,
            'class' => 't',
            'is_bool' => true,
            'value' => $newsletter,
            'values' => array(
                array(
                    'id' => 'newsletter_on',
                    'value' => 1,
                    'label' => $this->trans('Enabled', array(), 'Admin.Global'),
                ),
                array(
                    'id' => 'newsletter_off',
                    'value' => 0,
                    'label' => $this->trans('Disabled', array(), 'Admin.Global'),
                )
            ),
            'hint' => $this->trans('This customer will receive your newsletter via email.', array(), 'Admin.Orderscustomers.Help'),
        );
    
    评论

报告相同问题?