It is currently Mon Sep 06, 2010 12:08 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to quickly format inPut radio to have question on top
PostPosted: Thu Jul 15, 2010 2:14 pm 
Offline

Joined: Tue Jun 29, 2010 4:43 pm
Posts: 2
I would like to have an easy way to format some questions on a form in radio format, so that the question is on the top taking the whole form width, then a list of radio buttons underneath, one per line to select from, like this:

How do you feel about working for Mrs Smith?
() I like it a lot
() I don't like it much
() I really like it

I can't find an easy way to do this, any ideas? When I use this:

'itemlayout' => "<tr><td align=left>%radio%</td><td align=left>%label%</td></tr>",
'layout' => "<table><tr><td colspan=2>$question</td></tr>%s</table>",

I get the question on top, but a huge gap on the left where I have used a blank display name.

Any ideas for a quick way to achieve my preferred layout?

I have the same problem with text boxes, I want the question across the top and then the text box underneath.

Thanks.


Top
 Profile E-mail  
 
 Post subject: Re: How to quickly format inPut radio to have question on top
PostPosted: Fri Jul 16, 2010 10:08 am 
Offline
Site Admin

Joined: Thu Jan 19, 2006 2:38 pm
Posts: 94
The first thing to try is a different form layout! The default layout in Clonefish is "tabular", however, the "rowbyrow" layout is the one that gives the result you're looking for: a form without table, tr and td tags, with input fields below labels. To change the layout, just add the following:

Code:
$form->layout = 'rowbyrow';


Additionally, the easiest way to get the radio layout is
Code:
'itemlayout' => '%radio% %label%<br />'

(as the radio button sizes are equal, all the buttons will align fine)

Well, that sums up the solution - now some notes on what the problem was. Clonefish renders the forms based on the $form->layouts[ $form->layout ] array.
Element row HTML code (including the displayname, actual input field, etc.) comes from $form->layouts[ $form->layout ]['element'], and can be overridden by the 'rowlayout' setting for an element.

The 'layout' setting for an element is strictly related to the element itself - not the entire row. Let's assume we follow the harder path, and go on with the default "tabular" form layout. In this case we need to cope with the table tags provided by the tabular layout, and so should create the following config to achieve the same results:

Code:
$config = Array(
  'element' => Array(
    'type' => 'inputRadio',
    'rowlayout' => // entire input element row, colspan'd to fit the layout
       '<tr %errorstyle%>'.
         '<td colspan="3">' .
         '<label for="%id%">%displayname%</label>%erroricon%<br />' .
         '%prefix%%element%%postfix%<br />' .
         '%errordiv%' .
       '</td></tr>',
    'layout' => '<table>%s</table>', // container for the radio options
    'itemlayout' => '<tr><td>%radio%</td><td>%label%</td></tr>', // actual radio option layout
  )
);


I hope the above helped you. You can find further details on page 3 of the Tour, and on the class properties page in the Reference.


Top
 Profile  
 
 Post subject: Re: How to quickly format inPut radio to have question on top
PostPosted: Wed Jul 21, 2010 1:04 pm 
Offline

Joined: Tue Jun 29, 2010 4:43 pm
Posts: 2
Thanks for that, the alternative layout idea works a treat and made everything much simpler, so thanks for that and for the other layout ideas. Having only been using this for 2 days there's a lot to get to grips with, but it's already saved me loads of programming time.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group