B
B
Bogdan2016-02-11 19:26:34
PHP
Bogdan, 2016-02-11 19:26:34

How to correctly set parameters in the constructor of the Varien_Data_Form class in Magento?

Created a simple form with one text field and "accept" button. Nothing happens when pressed. The only assumption is that I wrote the attributes incorrectly in the constructor of the Varien_Data_Form class. Where is the mistake anyway?
Here is the code itself:

include_once 'app/Mage.php';
Mage::init();

$form = new Varien_Data_Form(array(
  'name' => 'form',
  'action' => /*'webinse_process.php'*/Mage::getUrl('webinse-test.loc/Webinseprocess.php',
    array('name'=> Mage::app()->getRequest()->getParam('name'))),
  'method' => 'post'
));
$helper = Mage::helper('core');
$form->setForm($form);

$fieldset = $form->addFieldset('webinse-form', array('legend' => $helper->__('Here\'s form')));

$fieldset->addField('name', 'text', array('label' => $helper->__('Enter your name'), 'name' => 'name_label'));
$fieldset->addField('submit', 'submit', array('value' => 'Accept'));

echo $fieldset->toHtml();

PS All files are on the local server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Gerasimenko, 2016-05-25
@Hide

Please note that as a result of executing your code, you will not find the form tag in the source code of the html page . Replace the last line of code with this:

$form->setUseContainer(true);
echo $form->toHtml();

And delete the line
She is superfluous.
The error is that you do not have a form as such in the browser, i.e. nowhere to submit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question