Question

I have make a little Extension for Magento 1.6.2. I managed to write code in the backend-system to create a EAV Model to the database and I can write/read items from it like this tutorial: http://www.pierrefay.com/magento-admin-gridview-85

How can I use the following Forms in the frontendsystem, .. I have see there are dont classes like Mage_Adminhtml_Block_Widget_Form. I dont want to use own HTML constructions, want to get I want Magento look and feel. Have anyone a idea how to make own forms in magento frontend with magento classes?

class Extension_Name_Adminhtml_Printcatalog_Edit_General_Form extends Mage_Adminhtml_Block_Widget_Form
{

    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();
        $this->setForm($form);
        $fieldset = $form->addFieldset('printcatalog_form',
                        array( 'legend' => __('Allgemeine Informationen')));

        $fieldset->addField('catalog_name', 'text',
                array(
                    'label' => __('Katalogname'),
                    'class' => 'required-entry',
                    'required' => true,
                    'name' => 'catalog_name',
        ));

        $fieldset->addField('release_date', 'text',
                array(
                    'label' => __('Erscheinungsdatum'),
                    'class' => 'required-entry',
                    'required' => true,
                    'name' => 'release_date',
//                                        'image'  => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'/adminhtml/default/default/images/grid-cal.gif',
//                                        'format' => 

Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), 
            ));

        if (Mage::registry('printcatalog_data'))
        {
            $form->setValues(Mage::registry('printcatalog_data')->getData());
        }

        return parent::_prepareForm();
    }

}

?>
Was it helpful?

Solution

Not possible out of the box, all magento front-end forms are hard coded. As you can see in the class you provided it is part of the Adminhtml module (Mage_Adminhtml_Block_Widget_Form), which is for the administration dashboard within magento.

The amount of development to integrate a form class like in your code is not worth the time or flexibility of a hardcoded front-end form ... in most cases. If the majority of your continued development revolved around forms, then I'd reconsider building out abstract form classes to help in the creation of your forms via the controller.

On a higher note, Magento does provide a fairly decent javascript validation system for your front-end.

OTHER TIPS

You should look into Zend_Form, which came around after Magento/Varien's original form implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top