Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
if a form element or a field (aka a Field UI field) has a suffix set, and in the form render array an Ajax callback is added, the following error will be displayed and the field suffix will contain the text "Array":
Notice: Array to string conversion in Drupal\bootstrap\Utility\Element->appendProperty() (line 173 of themes/contrib/bootstrap/src/Utility/Element.php).
Drupal\bootstrap\Utility\Element->appendProperty('field_suffix', Array) (Line: 95)
Drupal\bootstrap\Plugin\ProcessManager::processAjax(Object, Object, Array) (Line: 58)
Drupal\bootstrap\Plugin\ProcessManager::process(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 998)
Drupal\Core\Form\FormBuilder->doBuildForm('bootstrap_form_test', Array, Object) (Line: 1061)
Drupal\Core\Form\FormBuilder->doBuildForm('bootstrap_form_test', Array, Object) (Line: 562)
Drupal\Core\Form\FormBuilder->processForm('bootstrap_form_test', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce:
To help reproduce this issue a small custom module is attached in a Zip file, the module provides a route and a form which helps demonstrate the issues.
- Install Bootstrap theme.
- It's a good idea to turn on "All messages, with backtrace information" under Configuration > Logging and errors
- Download and enable the custom module attached to this issue in the Zip file bootstrap_form_test.zip.
- Once the module is enabled, navigate to the path /bootstrap_form_test
- On that page is a simple form with two text fields, you should see the same error message shown above, and the text "Array" printed in the suffix of the "Test" field.
Comment | File | Size | Author |
---|---|---|---|
#12 | 3085493-12.patch | 7.48 KB | markhalliwell |
#5 | 3085493-5.patch | 2.07 KB | markhalliwell |
Comments
Comment #2
markhalliwellNeed some steps to reproduce with a clean install.
Comment #3
AaronMcHaleI have updated the IS with instructions on how to reproduce the issue, as was as attached a small custom module which allows easily demonstrating the issue.
The custom module contains a route and a simple form, the form provides a Ajax text field with a suffix, which causes the issue to appear. Turns out the issue isn't limit to fields generated by the Field UI, so have updated the IS to reflect that as well.
Comment #4
AaronMcHale@markcarver do you have any idea how we might overcome this, even if it's just a temporary workaround on our end to disable the way the Bootstrap theme interacts with Ajax enabled fields?
Thanks,
-Aaron
Comment #5
markhalliwellSee if this helps.
Comment #6
AaronMcHaleThat does seem to have fixed the issue for me, thank you
Comment #9
markhalliwellComment #11
markhalliwellSo, this isn't really fully fixed. Specific properties should always be rendered to strings, regardless if an array or Element was provided. This is due certain core properties (like prefix/suffix) expecting them to always be strings.
This needs a more robust solution.
Comment #12
markhalliwellComment #16
markhalliwellThis apparently needs some work as these changes are causing some very unintended side-effects: #3112673: Search button gone away
edit: I've gone ahead and reverted the commits to the 8.x-3.x and 8.x-4.x branches.
Comment #19
mike421 CreditAttribution: mike421 commentedIs this a Webform issue, and is it fixed? I also have this issue, has taken me ages to debug. I get the message
Notice: Array to string conversion in Drupal\bootstrap\Utility\Element->appendProperty() (line 173 of themes\bootstrap\src\Utility\Element.php), plus a stack trace very similar to the above
I am using an Ajax callback on the form. and webform 6.0.2 Drupal 8.9, with suffices on my webform fields
I am not sure the error is Webform, it only appears when I am using the Bootstrap theme 8.x-3.16 (with Bartik it doesnt happen). All my fields on the webform with a suffix have the word "Array" appended to the suffix.
Comment #21
shelaneThis theme will not be supported for Bootstrap 4. See alternative themes for this support.