3

I am trying to add what will become a slider into the administration area. I have an input box showing (that will eventually hold the slider value) by creating a new attribute in my install script:

$installer->addAttribute(
    'catalog_category',
    'my_custom_attr',
    array(
        'label' => 'My Custom Attribute',
        'group' => 'My Group',   
        'type'  => 'int',
        'class' => 'validate-number',
        'required' => false,
        'default' => 50,
        'renderer' => 'mymodule/adminhtml_catalog_category_widget_slider'
    )
);

I need to add some html after the input field has been rendered, so I created this class:

class Mynamespace_Mymodule_Block_Adminhtml_Catalog_Category_Widget_Slider extends Varien_Data_Form_Element_Text
{
    public function getAfterElementHtml()
    {

        $html = parent::getAfterElementHtml();
        return $html."  <div id=\"slider_track\"><div id=\"slider_handle\"></div></div>";
    }
}

The above class resides in app/code/local/Mynamespace/Mymodule/Block/Adminhtml/Catalog/Category/Widget/Slider.php so should be getting called no problem but no extra HTML is getting added.

1
  • Have you looked at the value for frontend_input_renderer in the catalog_eav_attribute for the new attribute you've added? Is is actually populated? I think @oleksii.svarychevskyi is on the right track.
    – beeplogic
    Jan 23, 2014 at 17:53

1 Answer 1

2

Seams like it is because you use 'renderer' key for renderer. For that purpose Magento needs 'input_renderer' key.

$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'example_field', array(
    'group'             => 'General',
    'type'              => 'text',
    'backend'           => '',
    'input_renderer'    => 'test/catalog_product_helper_form_example',//definition of renderer
    'label'             => 'Example field',
    'class'             => '',
    'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
    'visible'           => true,
    'required'          => false,
    'user_defined'      => true,
    'searchable'        => false,
    'filterable'        => false,
    'comparable'        => false,
    'visible_on_front'  => false,
    'unique'            => false,
    'apply_to'          => 'simple,configurable,bundle,grouped',
    'is_configurable'   => false,
));
2
  • I've also had to use "frontend_input_renderer" as the key in some cases, just don't remember which.
    – beeplogic
    Jan 23, 2014 at 17:59
  • Is it the same for a customer attribute ? Jul 27, 2016 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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