Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 05:44 AM
Cristian's Avatar
Administrator
 
Join Date: Feb 2007
Location: Sibiu, Romania
Posts: 99
Default Styling Zend_Form generated forms

I am wondering which would be the best ways to style Zend_Form elements in case of complex forms. Question is both related to selecting proper decorators and css...

Some questions may occur:
1. How to have multiple elements on same line. Not using display groups... So instead of having elements as:

label1
field1

label2
field2

.....

To have rather


label1 label 2
field1 field2


2. How is possible to display multiple fieldsets on same "line" (arranged horizontally, similar with question 1. ) and without that ugly fieldset border.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:53 PM
Junior Member
 
Join Date: Apr 2008
Posts: 7
Default

Try to decorate the form. There are quite an examples for decorating the forms in the framework manual, or just use google
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-06-2008, 08:57 AM
Junior Member
 
Join Date: Apr 2008
Posts: 4
Default

What an answer ! Very Useful !!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-03-2008, 04:17 AM
Junior Member
 
Join Date: Jun 2008
Posts: 2
Default

Useless answer and this is exactly what Im trying to do. Does anyone have a specific solution to the problem besides "read the manual"? Ive already read through the docs and they are poorly written in this area, and not enough to give a good understanding. Perhaps if I give a specific example someone can help? Here is setting up the form element:

$gender = $form->createElement('radio', 'gender');
$gender->setLabel('Gender')
->addMultiOption('Male', 'male')
->addMultiOption('Female', 'female')
->setAttrib('class','radio')
->setRequired(true);

will generate the following code:

<dt><label for="gender" class="radio required">Gender</label></dt>
<dd>
<label style="white-space: nowrap;"><input type="radio" name="gender" value="Male" class="radio">male</label><br /><label style="white-space: nowrap;"><input type="radio" name="gender" value="Female" class="radio">female</label></dd>

How can I remove the "<br/>" from the output code? I know there are multiple ways to do this but what is the easiest?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-03-2008, 08:44 AM
Junior Member
 
Join Date: Jul 2008
Location: Ahmedabad
Posts: 8
Default

How could we pass form name and enctype dynamically? For more clarity below 2 lines I have added in model file.

PHP Code:
$this->setName('category');
$this->setAttrib('enctype''multipart/form-data'); 
Now I want to create .phtml file(view). Here I don't want to use <?php // echo $this->form; ?> Instead of I'm creating phtml file as per my format. How could I get form name and enctype in that form.

<form id="???" enctype="???" action="<?php echo $this->url(array('action'=>'edit')); ?>" method="post" >
__________________
Amit Shah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-03-2008, 05:20 PM
Member
 
Join Date: Jun 2008
Location: Florida
Posts: 76
Default

I don't know off the top of my head if it is possible to have multiple <dd> items on the same line, but I know that it is possible with ordered or unordered lists using:
Code:
white-space: nowrap;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-05-2008, 05:00 AM
Junior Member
 
Join Date: Jul 2008
Location: Ahmedabad
Posts: 8
Default

Ok.. I found the solution. getAttrib() function we can use to get name and other attribute of the form which we have set in model.

HTML Code:
<form id="<?php echo $this->form->getAttrib('name'); ?>" enctype="<?php echo $this->form->getAttrib('enctype'); ?>" action="<?php echo $this->url(array('action'=>'edit')); ?>" method="post" >
Cheers.
__________________
Amit Shah
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB 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 05:01 AM.