I haven't found anyone with this problem before, but theming webforms seems to be a tricky thing that few are attempting. I have read up on the forms API and the theming instructions in the webform module, and have implemented them in a form.

Essentially, I have added a new fieldset around various form items eg. 2 phone number inputs go into a phone fieldset. This works very well. However, in creating the new fieldset, the old form items still appear in the form. Is there any way to remove these form items using the theme. Currently, I can remove them by CSS - set all .form-item classes to display:none and then set display:block on all #fieldset .form-item. Is there a better way to do this?

Comments

quicksketch’s picture

You can prevent form items from appearing in themes simply be unsetting the previous form element. So if you have
$form['item'] and you move it into $form['parent-item']['item']. Just do an unset($form['item']) to remove the item at the old location.

You're right, not many people theme webforms (from what I've heard at least). I tinkered with fieldsets and forms a while back, but it didn't work out quite as a I had hoped. Fortunately, I'm putting together a fieldset component and re-working webforms a bit to handle it. You might want to hold off on this all-together for a few days, since I'll probably commit a new version of webform (with fieldsets) within the week.

davemybes’s picture

Thanks for the unset tip. I think I'll go ahead and play with the theming anyway, just to get a handle on how it works. But I'll be sure to check out your new version as soon as it comes out. This is an awesome module, by the way. I tried to write something like this (only way more basic), but soon got lost - I'm not yet a real coder. Just going through the process makes me appreciate people who release modules like this.

One other thing I was wondering about. Is it very complicated to wrap each form-item in a div that has a unique id (or give each form-item a unique id)? I realize you already have id's for each input type, but if I use those to reposition with CSS, the label gets left behind. Ideally, the user could enter the desired id themselves when creating each form item. The reason I suggest this is because the id's that are currently used for the various inputs sometimes have spaces in them, and this is not allowed in CSS. Hence, you cannot style it specifically anyway.

I hope that doesn't sound too demanding, but I think it would solve a lot of formatting issues that people have been having. But, for now, I will use the theming options. What I can do later is post a tutorial on how to use theming in a step-by-step manner, from a newcomer's perspective.

Thanks again for a great module.

quicksketch’s picture

Status: Active » Closed (fixed)

I opened a new issue for your second request.

http://drupal.org/node/75398