Is there a way to add a custom form element to a Magento Adminhtml form without placing the custom element in the lib/Varian
folder?
I've tracked down the code that's essentially a Varian_Data_Form_Element_
factory
public function addField($elementId, $type, $config, $after=false)
{
if (isset($this->_types[$type])) {
$className = $this->_types[$type];
}
else {
$className = 'Varien_Data_Form_Element_'.ucfirst(strtolower($type));
}
$element = new $className($config);
$element->setId($elementId);
if ($element->getRequired()) {
$element->addClass('required-entry');
}
$this->addElement($element, $after);
return $element;
}
So, if I'm reading this correctly, I ensure that an EAV attribute's frontend returns a specific fieldType, (such as supertextfield
) and the system will instantiate/render a Varien_Data_Form_Element_Supertextfield
when displaying this attribute's editing form.
This is well and good, but it means I need to include my custom form element in the lib/Varian
folder hierarchy. Given how module oriented Magento is, it seems like this is doing it wrong.
I realize I could jank around with a custo autoloader or symlinks in the lib, but I'm primarily interested in learning if there's
A canonical way to add custom form elements for attributes
A canonical way to customize the Magento autoloader.