There is any plan to support horizontal forms? http://twitter.github.com/bootstrap/base-css.html#forms

Comments

zmove’s picture

Same here. Its quite complex actualy to theme form horizontaly.

It would be great to have a module, or in the theme option that list all the drupal form and you can check the form you want to see horizontal.

Regards,

Alex

sunshinee’s picture

Issue summary: View changes

I'm working on this for a project and will submit a patch for review when complete. May be a little while, though. :)

jeff h’s picture

@sunshinee — you've had a little while, I want your work already :D

But seriously — Drupal is a giant pain when it comes to the markup it wants to put around form fields, and what it allows you to put attributes on. For example, in order to put attributes on field labels such as col-sm-x, I had to override theme_form_element_label() and make it use a custom attribute (which I called #label-attributes).

I'm wondering if a form-level switch could be made to enable this on any form. Eg something like:

      $form = drupal_get_form('some_form_id');
      $form['#bootstrap']['form_horizontal'] = TRUE;

This could then trigger some theme-level magic which rejigs the form field rendering so each field is classed and wrapped appropriately for Bootstrap. I propose we default to col-sm-3 on labels and col-sm-9 on fields. This could optionally be customised on each field, using the #bootstrap idea from above to trigger useful markup on fields e.g.

$form['report_title'] = array(
  '#type' => 'textfield',
  '#title' => t('Field title'), 
  '#description' => t('Field description.'),
  '#bootstrap' => array(
    'grid_label' => 'col-sm-2',
    'grid_field' => 'col-sm-10',
  ),
);  

Initially this would be enabled on a form via a form_alter() but conceivably a config UI could be created allowing any form to be made horizontal.

@theme_maintainers — would you consider rolling in something like this?

sunshinee’s picture

@jeff-h I know, right?

In all honesty, I ended up having another project take priority over this one (surprise! ugh!). I think we're looking toward a similar end. My thought was to make a theme setting to enable horizontal forms, with an input field for the form IDs to be rendered horizontally. The same could be done for inline forms.

Admittedly, this could be more complex than I envisioned. I LOVE the idea of a per-form setting, but am hesitant about the many ways this could go wrong in terms of support for modules and custom forms. That isn't to say the approach I came up with is better, but it's what I've been favoring.

Would love your thoughts on this as I should be able to refocus on this in the next couple of weeks.

~Joy

markhalliwell’s picture

Version: 7.x-2.x-dev » 7.x-4.x-dev
Status: Active » Postponed

This is likely going to happen in the next major release, probably via a companion module (themes can only do so much) that can provide an easy to use UI to configure core forms and webforms.

markhalliwell’s picture

Title: Horizontal forms support » Better FAPI/Webform Support
Category: Feature request » Plan
markhalliwell’s picture

Version: 7.x-4.x-dev » 8.x-4.x-dev

Changing to proper branch version for #2554199: Bootstrap 4.

jrockowitz’s picture

@marccarver I have started to introduce some very basic Bootstrap fixes/workarounds into Webform 8.x-5.x.

I do not think you need to do anything because I am willing to bet someone is going to have a major D8 project that is using both Bootstrap and Webform and they can start addressing any new issues that come up.

@see #2862483: Down arrow icon won't display on Select2 drop-down element with Bootstrap theme

markhalliwell’s picture

Status: Postponed » Closed (works as designed)

Considering that webform 8.x-5.x is doing it's own thing, I don't think this is going anywhere anytime soon.