Jump to content

Form not POSTing


ShaolinF

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.