I have meet 2 bugs when use bootstrap theme.
1. Repeat field_suffix and field_prefix
I add a new field with "field suffix" and "field prefix" properties on Manage Fields page for "Page" content type, but it will rendered repeat suffix and prefix on my create new page node page. I also tested with custom form element with that properties, same issues.


I found if you used #input_group properties, rendered correct, because the #field_prefix and #field_suffix values will be remove if have #input_group or #input_group_button on line 58-64 of file "src/Plugin/Preprocess/FormElement.php". But drupal core form element doesn't built-in these properties, so my solution is just map the prefix and suffix when input_group property enabled of file "src/Plugin/Preprocess/Input.php".
src/Plugin/Preprocess/FormElement.php
// Remove the #field_prefix and #field_suffix values set in
// template_preprocess_form_element(). These are handled on the input level.
// @see \Drupal\bootstrap\Plugin\Preprocess\Input::preprocess().
if ($variables->element->hasProperty('input_group') || $variables->element->hasProperty('input_group_button')) {
$variables['prefix'] = FALSE;
$variables['suffix'] = FALSE;
}
src/Plugin/Preprocess/Input.php
// Map the element properties.
$variables->map([
'attributes' => 'attributes',
'icon' => 'icon',
'type' => 'type',
]);
// Just map the prefix and suffix when input_group property enabled.
if ($variables['input_group']) {
$variables->map([
'field_prefix' => 'prefix',
'field_suffix' => 'suffix',
]);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | bootstrap-input_group_issues-2723847-12.patch | 6.76 KB | hswong3i |
| Snip20160512_5.png | 51.16 KB | everright |
Comments
Comment #2
everright commentedComment #3
buddaPrefix and suffix labels are now appearing correctly around the form field in my test of just Drupal Core and Bootstrap 3 theme enabled and a custom field added to the default Contact form.
Comment #4
buddaWorking test field with prefix and suffix labels.
Comment #5
markhalliwellI'll need to step through this. There's a lot of things changing in that patch and I need to make sure it's not doubling unnecessary work.
Furthermore, I'm not seeing from the above screenshots that actual Bootstrap input groups are working properly.
Comment #6
estoyausenteI applied the patch and now it's working correctly but I understand the @markcarver position.
Can we fix this bug without apply whole code? Without apply the input groups and then, if we can and want, implement the input group bootstrap component (http://getbootstrap.com/components/#input-groups).
I don't know too about theming and less about theming in D8 but I'm using bootstrap currently and I need this resolved and want to help.
@markcarver if you don't want apply this patch, what is your proposal? Or you prefer that we work in this using bootstrap input groups?
Thanks.
Comment #8
markhalliwellOk. I've stepped through this and the above patch was verbosely unnecessary. The above commit just removes the prefix and suffix rendering on form_element since it's handled at the input level anyway.
Comment #9
edysmpThe committed no fix the search page :( Actually is broken. With #2 worked.
Comment #10
markhalliwellYes it did. I did the exact same steps in the OP to reproduce and fixed it.
Edit: including testing the submit button
Comment #11
edysmpHi @markcarver, ok I tested with Drupal 8.0.4 and Bootstrap 8.x-3.0-rc1 and search page no works for anonymous users. Bartik is good.
Thanks.
Comment #12
hswong3i commented@markcarver sorry that latest drupal-8.1.6 + bootstrap-8.x-3.x-dev not works in search page, anonymous user still can't submit form. Also, bartik is good.
Patch reroll from #2 via latest bootstrap-8.x-3.x-dev, let's check again?
Comment #13
hswong3i commentedConfirmed patch from #12 works with search page form submit.
Before search form submit:

After search form submit:

Comment #14
markhalliwell