1

What is the quickest way to render the attributes of a Mage_Eav_Model_Entity_Abstract in Mage_Adminhtml_Block_Widget_Form?

1

Thanks to Marius's advice I solved my problem in this way.

In _prepareForm() of class that extends Mage_Adminhtml_Block_Widget_Form I do this operation:

protected function _prepareForm() {
    $identify=1;
    $dataModel=Mage::getModel('namespace_module/modelName')->load($identify);

    $form = new Varien_Data_Form();
    $form->setDataObject($dataModel);
    $fieldset = $form->addFieldset('dataModelform',
        array(
            'legend'=>Mage::helper('namespace_module')->__('Name of Fieldset'),
            'class'=>'fieldset-wide',
        )
    );

    $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
        ->setEntityTypeFilter($dataModel->getEntityTypeId());
    foreach ($attributes as $attribute) {
        $attribute->setEntity(Mage::getResourceModel('namespace_module/modelName'));
    }
    $this->_setFieldset($attributes, $fieldset, array());

    $formValues = $setting->getData();
    $form->addValues($formValues);
    $form->setFieldNameSuffix('dataModelElement');
    $this->setForm($form);
}

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.