Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7731311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:26:57+00:00 2026-06-01T06:26:57+00:00

I am working with zend just recently. I discovered this ViewScript decorator for form

  • 0

I am working with zend just recently. I discovered this ViewScript decorator for form and I find it a best alternative of using the
classic Zend Form Decorators. But I have problem on displaying the form. I got the code working but no display I get from the view.

Here are my codes:

Form:

class Application_Form_Registration extends Zend_Form
{
    public function init()
    {   
        $username = new Zend_Form_Element_Text("username");
        $submit = new Zend_Form_Element_Submit("submit");
        $this->setAction("/test.php");
        $this->setMethod("get");
        $this->addElements(array($username, $submit));
        $this->setElementDecorators(array(
          array('ViewScript', array(
            'viewScript'=>'test.phtml'
          ))
        ));
    }
}

Controller:

class IndexController extends Zend_Controller_Action
{
    public function init()
    {
    }

    public function indexAction()
    {
        $form = new Application_Form_Registration();
        $this->view->form = $form;

    }
}

test.phtml (My ViewScript)

<form action="<?php $this->escape($this->form->getAction()); ?>">
<div style="width: 100px; height: 100px; background: blue;">
    <?php echo $this->element->username; ?>
    <?php echo $this->element->submit; ?>
</div>
</form>

And my view (index.phtml)

<?php echo $this->form; ?>

Did I missed something and / or made wrong with the above code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:26:58+00:00Added an answer on June 1, 2026 at 6:26 am

    Replace

      $this->setElementDecorators(array(
                  array('ViewScript', array(
                    'viewScript'=>'test.phtml'
                  ))
                ));
    

    with

    $this->setDecorators(array(
                  array('ViewScript', array(
                    'viewScript'=>'test.phtml'
                  ))
                ));
    

    You have bassically overrided default decorator ‘ViewHelper’ hence there is nothing to show .

    Both form (html form tag) and form elements (input type text,radio etc) uses decorators to display themselves . By calling setElementDecorators on Zend_Form instance you are overriding form elements decorators not form decorators for that we need to use setDecorators instead .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Zend. I managed to get the basic working (using zf
I have finally got a zend view helper working using this in my helper
I've been using Zend Framework and just living with this problem for a while,
I have just started working on a project and I am using zend framework
I've been working with Zend Framework (using Doctrine as the ORM) for quite a
I am working on zend. I have a form with some checkboxes. I want
I'm using Zend forms. I have a form to add a row to a
I am working with Zend framework and just hate the fact that I seem
The intellisense feature in zend studio 7 just stopped working. I do as usual
Just started working with the Zend Framework Zf Tool and I've already come across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.