1

There is a nice little feature when you add form fields to the system configuration where you can use:

<my_field>
    ...
    <validate>some-class</validate>
    ...
</my_field>

This will add a class to your <input> form field which is useful for all sorts of things. Is there a method to do the same when declaring a widget parameter in widget.xml?

1 Answer 1

2

I scoured through Magento source, and I did not find where an additional value would be set in widget.xml. While it's a bit annoying, I resorted to using my own <type>.

My widget.xml contains:

<my_param translate="label">
    <required>1</required>
    <visible>1</visible>
    <label>My Label</label>
    <type>module/my_custom_block</type>
</my_param>

The annoying part is that my block class only contains:

class Module_Name_Block_My_Custom_Block extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element
{
    public function render(Varien_Data_Form_Element_Abstract $element)
    {
        $element->addClass('my-class');
        $this->_element = $element;
        return $this->toHtml();
    }
}
1
  • Old old question, but I ran into this recently. I didn't find a way to do this and your solution seems like the only proper way to go about it. However, there IS the setFrameTags($open, $close = null) method. Which would technically make it possible to do something like setFrameTags('input class="foo"') but it's nasty.
    – Rian
    Commented May 29, 2018 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.