0

I'm new to Magento. I've built some grid and Edit forms, but I don't know how to add multible edit block and tables in the same page.

What I've built is something like this: enter image description here

What I need is something like this: enter image description here

This is my edit Form.php

class Ns_Thorleif_Block_Adminhtml_Commerciaux_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();
        $this->setForm($form);

        $fieldset = $form->addFieldset('commerciaux_form', array('legend' => 'Informations'));

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

        $fieldset->addField('city', 'text', array(
            'label' => 'City',
            'class' => 'required-entry',
            'required' => true,
            'name' => 'city'
        ));

        if ($commerciauxData = Mage::registry('commerciaux_data')) {
            $form->setValues($commerciauxData->getData());
        }
        return parent::_prepareForm();
    }
}
1

You can add another section with:

protected function _prepareForm()
{
    $form = new Varien_Data_Form();
    $this->setForm($form);

    // section one
    $fieldset = $form->addFieldset('commerciaux_form', array('legend' => 'Informations'));

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

    $fieldset->addField('city', 'text', array(
        'label' => 'City',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'city'
    ));

    // section two
    $fieldset = $form->addFieldset('commerciaux_form_2', array('legend' => 'Informations'));

    $fieldset->addField('your_field', 'text', array(
        'label' => 'Field Name',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'your_field'
    ));

    if ($commerciauxData = Mage::registry('commerciaux_data')) {
        $form->setValues($commerciauxData->getData());
    }
    return parent::_prepareForm();
}
  • but that will add the field in the same form block not in a separate one I think, I've tried but I didn't receive any change. – javaTodev May 18 '17 at 16:12
  • Added full code ... You can use the methods you've already uses. – sv3n May 18 '17 at 16:31
  • I'd like to add a grid(in the same form page) or table like this where and how I can implement this? – javaTodev May 23 '17 at 15:48

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.