简体   繁体   中英

Zend_Form not rendering

Folks, I'm having some problems making a form render/display in my webpage. Well, it works fine in my local server, but once I use the same code in a remote server, the webpage displays fine, but the form is missing.

Localhost:
OS: Win 7
PHP: 5.3.8
Apache: 2.2.21
Zend: 1.11.3

Remote Server:
OS: Linux CentOS release 5.5
PHP: 5.3.8
Apache: 2.2.3
Zend: 1.11.3

FeedbackForm.php

class forms_FeedbackForm extends Zend_Form {

public function init() {

$this->setAction('')->setMethod('post')->setName('feedbackForm');

$feedback = new Zend_Form_Element_Textarea('feedback');

$submit = new Zend_Form_Element_Button('submitButton');

$this->addElement($feedback)->addElement($submit);
} }

IndexController.php

class IndexController extends Zend_Controller_Action {

public function indexAction() {

$form = new forms_FeedbackForm();

  $this->view->form = $form; 

} }

index.phtml

echo $this->form;



However, if I replace the echo statement with print_r($this->form), I see the object details with both servers.

Use a capital for your class: Forms_FeedbackForm instead of forms_FeedbackForm. The autoloader doesn't find it on Linux.

Generally when problems like this occure between Linux and Windows servers it's a capital problem. Linux is case sensitive, windows isn't.

Your code looks fine. I suggest you set display exceptions on in your application.ini:

resources.frontController.params.displayExceptions = 1 And make sure your error view displays exceptions.

Make sure that your view looks like <?php echo $this->form; ?> <?php echo $this->form; ?> , otherwise, the PHP won't actually execute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM