Just started with 4.7....
I am porting a custom module right now. No problems with the new Form API so far except for inlining form items in edit mode.
What I am trying to achieve is:
Zip: [ ] City: [ ]
Is there a #prefix / #suffix to span form items so I can alter the css def of form-item to inline ?
<div class="container-inline">
[..] // zip and city fields
</div>
where css def would be
.container-inline .form-item
{
display:inline;
}
I searched the forums but no luck. Maybe I just used the wrong search keys.
Just started with 4.7....
I am porting a custom module right now. No problems with the new Form API so far except for inlining form items in edit mode.
What I am trying to achieve is:
Zip: [ ] City: [ ]
Is there a #prefix / #suffix to span form items so I can alter the css def of form-item to inline ?
<div class="container-inline">
[..] // zip and city fields
</div>
where css def would be
.container-inline .form-item
{
display:inline;
}
I searched the forums but no luck. Maybe I just used the wrong search keys.
Comments
Same here
I've been trying to track this one down too. What I've found is that the "label" fields aren't converting to inline like the divs. You'll find that if you omit the labels (a.k.a. #title), then the form elements will go inline.
I'll let you know if I find out more.
--= Jeff Robbins | www.lullabot.com =--
Progress?
Any success with this?
I added a "form-inline"
I added a "form-inline" class in my style.css:
In my custom phptemplate.inc (included in phptemplate.engine) I added the following function:
To get form elements displayed inline I call the above function this way:
For anyone coming across this
For anyone coming across this (somewhat ancient) discussion now - Drupal 7's default CSS includes a 'container-inline' class which will prompt any child DIVs or LABELs to be rendered inline (barring interference from other stylesheets).
Which is nice.
Under the Forms API this can be implemented like so:
++Andy
Developing Drupal websites for Livelink New Media since 2008
Here's a demo of how I made inline radio buttons for Drupal 7:
the demo: http://aswapathy.com/d79de/irb
the css:
the php:
You can use the "Contact Carl" menu option on the site if you have any questions.
Guys you are great!
Although this is an ancient thread, thanks for the help! Those last answers helped meg out!
Once again for this ancient
Once again for this ancient post:
Fields in-inline, but titles above?
I am starting to get my fingers around D7, but have not been able to figure out how to get a form to display the fields in-line, but keeping the titles above. A snippet from my code is below, but it produces:
First Name [ ] Last Name []
$form['user_name'] = array(
'#title' => t(''),
'#type' => 'fieldset',
'#attributes' => array('class' => array('container-inline')),
);
What I am trying to achieve is:
First Name Last Name
[ ] []
Phone
[ ]
Email
[ ]
etc.
Thanks
CSS
I think you'd need to approach this with CSS ... the form items should have a wrapping element around the label and field, you can either float them left or make them
display: inline-block
. Then, within the wrapper, just have the labels display as a block as normal.Here's a brief example, though naturally you'd have to look up the exact classes or IDs needed to identify the specific form items you want to style:
++Andy
Developing Drupal websites for Livelink New Media since 2008
add to FAPI docs?
as titled?
works great. thank you.
works great. thank you.