Zend Framework Forum

Go Back   Zend Framework Forum > Zend Framework General discussions > Resources for Developers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-2008, 03:38 AM
Junior Member
 
Join Date: Nov 2008
Posts: 3
Smile using Div with Zend Form

Hi All,

I am new to Zend Framework and trying to design UI using Zend_Forms. What I need to do is to switch between 2 divs using javascript. One div will have e.g First Name and Surname and other will have company name. I will switch between these divs depending on Individual and company selection. I tried to use used the following code:

$first_name = new Zend_Form_Element_Text('first_name');
$first_name
->setRequired(true)
->addValidator(new Zend_Validate_Alnum())
->addFilter('StringToLower')
->setLabel('First Name');

$surname = new Zend_Form_Element_Text('surname');
$surname
->setRequired(true)
->addValidator(new Zend_Validate_Alnum())
->addFilter('StringToLower')
->setLabel('Surname');

$form->addElement( $first_name );
$form->addElement( $surname );
$form->addDisplayGroup(array('first_name','surname'), 'individual');

$form->setDisplayGroupDecorators(
array(
'FormElements',
array('HtmlTag', 'tag' => 'div')
)
);

The problem I am having is that I get the div properly working but I don't get the id for the div. So I am not able to manipulate using javascript. Also I don't know how to hide or unhide the div using zend_form. Can somebody give me guidance on how to make div properly working using Zend_Forms?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-23-2008, 11:25 PM
Junior Member
 
Join Date: Nov 2008
Posts: 1
Default

Zend Form display groups and decorators with example Zend Framework Weblog appears to have the answer.

Code:
$form->addElement( $first_name );

$form->addElement( $surname );

$form->addDisplayGroup(array('first_name','surname'), 'individual'); 

$form->setDecorators(array(
'FormElements',
array('HtmlTag',array('tag'=>'div','id'=>'blah')),
'individual'
));
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-25-2008, 05:17 AM
Junior Member
 
Join Date: Nov 2008
Posts: 3
Default

Thanks melatbabel. You are great.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 07:38 PM.


Designed by: Miner Skinz Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0