ShaolinF Posted April 28, 2010 Share Posted April 28, 2010 Hi Guys I have setup a form to add users to a mailing list. However, whenever I submit it the action rejects it as its apparantly not using the POST method (when it is). Code attached below: <?php class Application_Form_MailingList extends Zend_Form { public function init() { $frontController = Zend_Controller_Front::getInstance(); $baseUrl = $frontController->getBaseUrl(); $this->setAction($baseUrl.'/index/joinlist') ->setMethod('POST') ->setName('mailingList'); $name = $this->createElement('text', 'name'); $name->addValidator('NotEmpty') ->addValidator('stringlength', false, 3) ->addFilter('StringTrim') ->setRequired(true) ->setLabel('Name'); $email = $this->createElement('text', 'email'); $email->addValidator('NotEmpty') ->addValidator('stringlength', false, 3) ->addFilter('StringTrim') ->setRequired(true) ->setLabel('Email'); $submit = $this->createElement('submit', 'Join List', array('class' => 'btn')); $this->addElements(array($name, $email, $submit)); } } IndexController: Code fails to recognise the POST in the joinlistAction method. I have hand checked the outputted HTML and the form is certainly set to POST. <?php class IndexController extends Zend_Controller_Action { public function indexAction() { $form = new Application_Form_MailingList(); $this->view->form = $form; } public function joinlistAction() { if(!$this->getRequest()->isPost) { return $this->_forward('index'); } } } ?> Link to comment https://forums.phpfreaks.com/topic/200058-form-not-posting/ Share on other sites More sharing options...
TheOnly92 Posted April 29, 2010 Share Posted April 29, 2010 Can you show us the HTML output? Link to comment https://forums.phpfreaks.com/topic/200058-form-not-posting/#findComment-1050463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.