1

I need to create a custom form that contains a list of checkboxes and textfields next to each other, as in:

enter image description here

There are many meal items in the list. Right now I'm using something like:

$form[$meal_type->sku] = array (
    '#type' => 'fieldset',
    '#attributes' => array('class' => array('container-inline')), 
  );
  $form[$meal_type->sku]['meal'] = array (
    '#type' => 'checkbox',
    '#title' => $meal_type->title,
    '#return_value' => $meal_type->sku,
  );
  $form[$meal_type->sku]['quantity'] = array (
    '#type' => 'textfield',
    '#default_value' => 1,
    '#size' => 5,

  );

This creates an individual fieldset for each meal item and quantity. I just wanted to see if there are any suggestions for a better approach. Thanks!

1 Answer 1

2

I ended up using a '#type' => 'container' instead of fieldset. And I used #prefix and #suffix in the children to add specific classes for spans and horizontal alignment etc.

One other thing that seemed useful but I ended up not using: template files for form theming. This is a very useful tutorial:

http://themery.com/dgd7/advanced-theming/forms/with-templates

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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