Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.