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

  • SEARCH
  • Home
  • 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 8205793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:23:59+00:00 2026-06-07T08:23:59+00:00

I am using zend framework and am trying to output a simple login form

  • 0

I am using zend framework and am trying to output a simple login form using zend form, MVC and OOP.

My code is below:
The Controller
IndexController.php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $this->view->loginForm = $this->getLoginForm(); 
    }

    public function getLoginForm()
    {
        $form = new Application_Form_Login;
        return $form;
    }
}

This is the form:
Login.php

class Application_Form_Login extends Zend_Form
{

    public function init()
    {
        $form = new Zend_Form;

        $username = new Zend_Form_Element_Text('username');
        $username
            ->setLabel('Username')
            ->setRequired(true)
        ;

        $password = new Zend_Form_Element_Password('password');
        $password
            ->setLabel('Password')
            ->setRequired(true)
        ;

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Login');

        $form->addElements(array($username, $password, $submit));

    }
}

And the view:
index.phtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>

    </head>

    <body>

        <div id="header">
            <div id="logo">
                <img src="../application/images/logo.png" alt="logo">
            </div>
        </div>

        <div id="wrapper">
            <?php echo $this->loginForm; ?>
        </div>
    </body>
</html>

I am new to Zend Framework, MVC and OOP, So this my best attempt at this following online advice, tutorials etc.

  • 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-07T08:24:04+00:00Added an answer on June 7, 2026 at 8:24 am

    You have inadvertently created a form with no elements, which is why nothing is appearing. In the init method of your form object you are creating a new instance of Zend_Form, $form which you then do nothing with, instead of adding the elements to the current instance. Change your class to this:

    class Application_Form_Login extends Zend_Form
    {
        public function init()
        {
            $username = new Zend_Form_Element_Text('username');
            $username
                ->setLabel('Username')
                ->setRequired(true)
            ;
    
            $password = new Zend_Form_Element_Password('password');
            $password
                ->setLabel('Password')
                ->setRequired(true)
            ;
    
            $submit = new Zend_Form_Element_Submit('submit');
            $submit->setLabel('Login');
    
            $this->addElements(array($username, $password, $submit));
        }
    }
    

    and it should work.

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

Sidebar

Related Questions

I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework
I am trying to build a Connect app using PHP and the Zend Framework.
I'm trying to do a group by using Zend framework. Here's my code: $table
Im trying to connect from PHP(Zend Framework) code to an aspx Web Service. I
I'm trying to develop a site using Zend Framework, but i have a problem:
I am trying to find the best way to implement Model using Zend Framework
I'm trying to create a REST service in zend framework. I'm using zend server.
I'am trying to retrieve an parameter passed in a url using the zend framework.
I'm currently using Zend Framework 2 beta for on PHP 5.4.4 to develop a
I'm using Zend framework and trying to get the results to be in a

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.