2

I'm trying to use an input renderer for a text attribute in my custom entity, however it doesn't seem to be working.

I'm creating my ambassador entity in my setup file like this:

<?php
/* @var $installer Mage_Eav_Model_Entity_Setup */
$installer = $this;

$installer->startSetup();

$installer->createEntityTables($installer->getTable('ambassadors/ambassador'));

$installer->installEntities(array(
    'ambassador' => array(
        'entity_model' => 'ambassadors/ambassador',
        'table' => 'ambassadors/ambassador',
        'attributes' => array(
            'type'           => 'varchar',
            'input'          => 'text',
            'label'          => 'Featured Color',
            'required'       => false,
            'input_renderer' => 'ambassadors/adminhtml_helper_color'
        )
    )
));

$installer->endSetup();

The attribute is created and assigned to my entity but it renders like a normal text input in my edit form in the backend, I was looking at the Mage_Eav_Model_Entity_Setup class and it looks like input_renderer doesn't get passed in the _prepareValues method so I think this is part of the problem:

protected function _prepareValues($attr)
{
    $data = array(
        'backend_model'   => $this->_getValue($attr, 'backend'),
        'backend_type'    => $this->_getValue($attr, 'type', 'varchar'),
        'backend_table'   => $this->_getValue($attr, 'table'),
        'frontend_model'  => $this->_getValue($attr, 'frontend'),
        'frontend_input'  => $this->_getValue($attr, 'input', 'text'),
        'frontend_label'  => $this->_getValue($attr, 'label'),
        'frontend_class'  => $this->_getValue($attr, 'frontend_class'),
        'source_model'    => $this->_getValue($attr, 'source'),
        'is_required'     => $this->_getValue($attr, 'required', 1),
        'is_user_defined' => $this->_getValue($attr, 'user_defined', 0),
        'default_value'   => $this->_getValue($attr, 'default'),
        'is_unique'       => $this->_getValue($attr, 'unique', 0),
        'note'            => $this->_getValue($attr, 'note'),
        'is_global'       => $this->_getValue($attr, 'global', 1),
    );

    return $data;
}

The Mage_Catalog_Model_Resource_Setup does pass this attribute but it still doesn't work if I use that class instead, however it works fine if I assign the attribute to the catalog or category entities so I assume that setup class is linked to those entities in some way? Do I have to do something else to enable custom input renderers in my entity? Do I have to initialise it differently?

Your Answer

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

Browse other questions tagged or ask your own question.