As the title describes, I am to style a webform and for that i need to surround specific fields in divs in order to give them their CSS properties and I have no idea how I should go about doing that. Also I'd like to do the same to the Submit button.

I've caught the form with hook_form_alter but no idea what to do after.


Why do you need a div?

Just use a field set and hide label and turn off the collapsible feature.

If anything this is more semantic than using a div in splitting up fields in a form. Visually will look excately the same and you can also use CSS class generated from the field set name in your styling.

  • yeap ended up using that after all. First time I am asked to create a form and was unfamilliar with the Fieldset component. Thanks anyway and here's a green check for you! – magtak Jan 16 '12 at 11:42
  • do you care to share how you added the 'fields' to a fieldset? can you do this with something like $form['field_name'] = array('#fieldset' => 'fieldsetname'); ? – FLY Apr 23 '12 at 14:31
  • You can do this via the UI. To do it programatically you would have to follow the FAPI instructions. – WestieUK Apr 23 '12 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.