0

I have created a custom module to save fields in database now want to get all the fields value into the form so they will be shown in admin:

Here is my adminform:

<?php
 class OptFirst_ReviewMyCompany_Block_Adminhtml_Form_Edit_Form extends
Mage_Adminhtml_Block_Widget_Form
 {
/**
 * Preparing form
 *
 * @return Mage_Adminhtml_Block_Widget_Form
 */
protected function _prepareForm()
{
 $form = new Varien_Data_Form(array(
 'id' => 'edit_form',
 'action' => $this->getUrl('*/*/save'),
 'method' => 'post',
 ));
 $form->setUseContainer(true);
 $this->setForm($form);
 $helper = Mage::helper('optfirst_reviewmycompany');
 $fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'),
 'class' => 'fieldset-wide'));
 $fieldset->addField('facebook', 'text', array(
 'name' => 'facebook',
 'label' => $helper->__('Facebook'),
 'value' => 'facebook.com'
 ));
 $fieldset->addField('google', 'text', array(
 'name' => 'google',
 'label' => $helper->__('Google'),
 ));
 $fieldset->addField('twitter', 'text', array(
 'name' => 'twitter',
 'label' => $helper->__('Twitter'),
 ));
 $fieldset->addField('linkedin', 'text', array(
 'name' => 'linkedin',
 'label' => $helper->__('Linkedin'),
 ));
 $fieldset->addField('yelp', 'text', array(
 'name' => 'yelp',
 'label' => $helper->__('Yelp'),
 ));
 if (Mage::registry('optfirst_reviewmycompany')) {
 $form->setValues(Mage::registry('optfirst_reviewmycompany')->getData());
 }
 return parent::_prepareForm();
}
}

This is the form in admin: enter image description here I want to create a view where all the form fields will be shown there database value.. is that can be done?

Thanks!

asked Nov 26, 2016 at 22:22

1 Answer 1

0

Try this,

<?php
 class OptFirst_ReviewMyCompany_Block_Adminhtml_Form_Edit_Form extends
Mage_Adminhtml_Block_Widget_Form
 {
{
 $form = new Varien_Data_Form(array(
 'id' => 'edit_form',
 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
 'method' => 'post',
 )
 );
 $form->setUseContainer(true);
 $this->setForm($form);
 return parent::_prepareForm();
 }
}

Create on more file Block/Adminhtml/ReviewMyCompany/Edit/Tab/Form.php

 <?php
 class OptFirst_ReviewMyCompany_Block_Adminhtml_ReviewMyCompany_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
 {
 $form = new Varien_Data_Form();
 $this->setForm($form);
 $fieldset = $form->addFieldset('modulename_form', array('legend'=>Mage::helper('proxelle')->__('Item information')));
 $fieldset->addField('facebook', 'text', array(
 'label' => Mage::helper('modulename')->__('Facebook'),
 'class' => 'required-entry',
 'required' => true,
 'name' => 'facebook',
 ));
}

I guess you missed folder structure for more Follow this http://kamleshkamble.blogspot.in/2013/02/custom-module-in-magento-with-custom.html

answered Nov 27, 2016 at 5:39
5
  • its giving error at this line $form = new Varien_Data_Form(); Commented Nov 29, 2016 at 17:46
  • Update your full error Commented Nov 29, 2016 at 17:54
  • it is some type of syntax error in IDE Commented Nov 29, 2016 at 18:01
  • screencast.com/t/dsHYYVOOn check here Commented Nov 29, 2016 at 18:03
  • change modulename into your modulename and change proxelle into your modulename Commented Nov 29, 2016 at 18:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.