For form fields using autocomplete, the form element class is set to 'form-text'. Bootstrap css uses 'form-control'. I've attached images showing how the form element is current rendered and how the form element is rendered if the class is 'form-control'.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shelane created an issue. See original summary.

shelane’s picture

FileSize
481 bytes
markhalliwell’s picture

Status: Active » Closed (works as designed)

The only way this could be happening is if bootstrap_textfield() was being invoked directly rather than going through Drupal's normal theming system (e.g. drupal_render(array('#theme' => 'textfield', ...) or theme('textfield, $variables);).

The form-control class is automatically added in bootstrap_pre_render() for a multitude of element input types.

shelane’s picture

Where this issue comes up for me is in a custom module where I have a form. This is the element as defined:

$form['site_landingpage'] = array(
'#type' => 'entityreference',
'#title' => t('Default front page'),
'#era_entity_type' => 'node',
'#era_bundles' => array('landing_page','advanced_page'),
'#default_value' => get_entity_id(),
'#size' => 40,
'#description' => t('Select landing page to use as front page.'),
);

In order to use this entityreference type, I used the entityreference_autocomplete module. That module defines the type with these:
'#theme' => 'textfield',
'#theme_wrappers' => array('form_element'),

I just see that in this template file in the theme that it is setting the class to form-text. If I change it in the template file to form-control, then the form element displays with the correct class.

markhalliwell’s picture

Component: CSS Overrides » Code
Assigned: Unassigned » markhalliwell
Status: Closed (works as designed) » Needs work

Hm. Guess I'm just getting used to D8 where this class is added at a template level, regardless of what element info was defined.

Yes, they define '#theme' => 'textfield" for their element type:
http://cgit.drupalcode.org/entityreference_autocomplete/tree/entityrefer...

I've taken a look at bootstrap_pre_render() and think it should probably be split up into theme hooks + element types.

I'll commit a fix shortly.

markhalliwell’s picture

Title: autocomplete and form element class name » Elements that use core #theme hooks don't get .form-control applied

Better title.

markhalliwell’s picture

Assigned: markhalliwell » Unassigned
Status: Needs work » Fixed
FileSize
2.58 KB

  • markcarver committed 6bcd213 on 7.x-3.x
    Issue #2804221 by markcarver, shelane: Elements that use core #theme...
m.stenta’s picture

I updated to Bootstrap 7.x-3.18 and it seems that Date fields that use the Date Select widget (which shows each date component as a dropdown select list) are no longer receiving the "form-control" class, so they are being rendered as dropdown selects using the browser's default styling. I found this commit which changed the behavior of how that class is applied, so I assume this is what caused it. Does it make sense to start a new issue to fix that and link to this? Or reopen this one?

markhalliwell’s picture

Does it make sense to start a new issue to fix that and link to this?

Yes, also provide screenshots and markup examples of before/after please.

m.stenta’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.