0

How can i use a simple php form in zend framework.

I am new to this framework,so please explain in detail.

Thanks in advance

5 Answers 5

2

You can use normal HTML forms. Some code snippets for your controller:

// Get all params (Notice: including URL params)
$this->getRequest()->getParams();

// Get single param
$this->getRequest()->getParam('paramName');

// Check if post
$this->getRequest()->isPost();
Sign up to request clarification or add additional context in comments.

Comments

1

See e.g.

9 Comments

I don't want to use the zend_form but i wish to use the simple html form.How to do this
@Ankhur Why not simply output some form HTML then? What do you need the Zend Framework for at all?
Means without using zend form ,you are saying that it will be somewhat not using the zend framework properly and actually wasting it
@Ankur not necessarily, but your question doesn't make much sense yet to me. What do you mean by a "simple form"? I think you need to explain in more detail what you are doing with the Framework and what exactly your question is.
I am using the zend framework in the usual prescribed manner but i want to use simple html form in place of zend form.So i wish to know how to integrate this form with the zend framework
|
1

Just create your form like you would normally but in your view file (index.phtml for example). It will work. Nothing special to do just open a <form> tag and start coding.

Comments

1

This helped me a lot At the beginning:

http://www.zendcasts.com/zend_form-introduction-part-1/2009/02/

http://www.zendcasts.com/zend_form-introduction-part-2/2009/02/

You should use Zend Form (not PHP form), it should be standard except in some special cases.

Comments

0

If you really want to use plain html forms you should at least consider Zend_Filter_Input for filtering/validation the userinput.

$filters = array('body' => array('StringTrim' , 'StripTags'));
$validators = array('body' => 'Alpha');

if (!$this->getRequest()->isPost()) {
    // display form;
    return;
}

$input = new Zend_Filter_Input($filters, $validators, $this->getRequest()->getParams());

if (!$input->isValid()) {
    // failed validation
    $this->view->messages = $input->getMessages();
    // redisplay form and show error messages
    return;
}

// form is valid, values are filtered 
echo $input->body

Comments

Your Answer

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.