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 6029027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:49:33+00:00 2026-05-23T04:49:33+00:00

I am busy with a new project based on zend framework. I have created

  • 0

I am busy with a new project based on zend framework. I have created the following form:

<?php
class Application_Form_User extends Zend_Form
{

    public function init()
    {
       $this->setMethod('post');
       $this->setAttrib('class','zf');
       $this->addElement('text', 'username', array(
        'label' => 'Gebruikersnaam:',
        'required' => true,
        'filters' => array('StringTrim'),
        'validators'=>array(
                array('Db_NoRecordExists',
                false,
                array(
                    'table'=>'user',
                    'field'=>'username'
                )
            ))
       ));
       $this->addElement('text', 'name', array(
        'label' => 'Volledige naam:',
        'required' => true,
        'filters' => array('StringTrim'),
       ));
       $this->addElement('text', 'email', array(
        'label' => 'Email:',
        'required' => true,
        'filters' => array('StringTrim'),
        'validators'=>array(
            'EmailAddress',
            array(
                'Db_NoRecordExists',
                false,
                array(
                    'table'=>'user',
                    'field'=>'email'
                )
            )
        )
       ));
       $this->addElement('password', 'password1', array(
        'label' => 'Wachtwoord:',
        'required' => true,
        'filters' => array('StringTrim'),
       ));
       $this->addElement('password', 'password2', array(
        'label' => 'Wachtwoord (controle):',
        'required' => true,
        'filters' => array('StringTrim'),
        'validators'=>array(array('Identical',false,'password1'))
       ));
       $this->addElement('radio','type',array(
            'label'=>'Gebruikers type:',
            'required'=>true,
            'multiOptions'=>array(
                'consumer'=>'Klant',
                'admin'=>'Beheerder'
            )   
        ));
       $this->addElement('text', 'mobile', array(
        'label' => 'Mobiel:',
        'required' => true,
        'filters' => array('StringTrim'),
       ));
        $this->addElement('textarea', 'address', array(
        'label' => 'Address:',
        'required' => true,
        'style'=>'width: 200px;height: 100px;'
       ));

       $this->addElement('submit', 'submit', array(
        'ignore'=>true,
        'label'=>'Toevoegen'
       ));
       $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));

    }
}

This form has a radio button with the values ‘Consumer’ and ‘Admin’. What i want is that when the value is ‘Consumer’ some extra fields will be shown, and when it is ‘admin’, other elements will be shown.

So when the value is Consumer I want as example those fields: Consumer ID, Consumer kvk number. When the user switches to the admin radio button this fields must disapear.(So it must is JS)

Is there a way to do this in Zend Form out-of-the-box? Or must i make my own HTML form?

Tom

  • 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-05-23T04:49:34+00:00Added an answer on May 23, 2026 at 4:49 am

    You can make something like this:

    public function init($data = false)
    {
       if (isset($data['type']) && $data['type'] == 'consumer') {
          // add element or hide element
       }
    }
    

    In the Controller you can get form data and pass it to the form ->init($data);

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

Sidebar

Related Questions

I'm using zend form in a non-zend project and I'm able to access Zend_Form
I have been busy in my project creating a webapp (in struts) that manages
I've quite new to Android development and specially Eclipse. I'm busy on a project
I am busy with a new project and am working on my repository layer.
Currently I'm busy on a project using XML messaging. I have one general schema,
I have a gui thread starting a new thread to do some busy things.
I have been busy with the cakePHP framework for a couple of months now
I'm quite busy with working with the Zend_Form object. I'm building a form which
I'm busy implementing the wurfl api using PHP, but somehow just can't seem to
I'm busy implementing a Graph ADT in C++. I have templates for the Edges

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.