Jump to content

Setting value of radio input added by overriding AdminCategoriesController.


Recommended Posts

Hi,

 

How can I set the value of the radio input added through $this->fields_form_override.

    public function renderForm()
    {
        $this->fields_form_override = array(
            array(
                'type' => 'switch',
                'label' => $this->l('Enable Product Customizer'),
                'name' => 'enable_product_customizer',
                'required' => false,
                'is_bool' => true,
                'values' => array(
                    array(
                        'id' => 'enable_product_customizer_on',
                        'value' => 1,
                        'label' => $this->l('Enabled')
                    ),
                    array(
                        'id' => 'enable_product_customizer_off',
                        'value' => 0,
                        'label' => $this->l('Disabled')
                    )
                )
            )
        );

        return parent::renderForm();
    }

I tried adding it through $this->fields_value, but it doesn't work because this variable is overwritten when calling parent::renderForm().

Edited by twicekilled (see edit history)
Link to comment
Share on other sites

fields_value didn't work because it was getting reset in the original controller here

        $this->fields_value = array(
            'image' => $image ? $image : false,
            'size' => $image ? filesize(_PS_CAT_IMG_DIR_.'/'.$obj->id.'.'.$this->imageType) / 1000 : false
        );

But cloning the whole renderForm method and returning AdminController::renderForm() at the end worked perfectly.

 

Thanks, NemoPS.

Edited by twicekilled (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...