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.

beingalex
  • 727
  • 2
  • 11
  • 25
  • 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 '14 at 17:53

1 Answers1

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,
));
Quantum
  • 553
  • 8
  • 35
oleksii.svarychevskyi
  • 5,136
  • 1
  • 16
  • 22