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.

  1. Install Bootstrap theme.
  2. It's a good idea to turn on "All messages, with backtrace information" under Configuration > Logging and errors
  3. Download and enable the custom module attached to this issue in the Zip file bootstrap_form_test.zip.
  4. Once the module is enabled, navigate to the path /bootstrap_form_test
  5. 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.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

AaronMcHale created an issue. See original summary.

markhalliwell’s picture

Need some steps to reproduce with a clean install.

AaronMcHale’s picture

Title: "Notice: Array to string conversion" when field has a suffix and a Ajax callback » "Notice: Array to string conversion" when form element or field has a suffix and a Ajax callback
Issue summary: View changes
FileSize
1.38 KB

I 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.

AaronMcHale’s picture

@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

markhalliwell’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev
Status: Active » Needs review
FileSize
2.07 KB

See if this helps.

AaronMcHale’s picture

That does seem to have fixed the issue for me, thank you

  • markcarver committed 1e0b292 on 8.x-4.x
    Issue #3085493 by AaronMcHale: "Notice: Array to string conversion" when...

  • markcarver committed c938ff8 on 8.x-3.x
    Issue #3085493 by AaronMcHale: "Notice: Array to string conversion" when...
markhalliwell’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

markhalliwell’s picture

Status: Closed (fixed) » Needs work

So, 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.

markhalliwell’s picture

Status: Needs work » Fixed
FileSize
7.48 KB

  • markcarver committed 229321f on 8.x-4.x
    Issue #3085493 by markcarver, AaronMcHale: "Notice: Array to string...

  • markcarver committed 9c84eca on 8.x-3.x
    Issue #3085493 by markcarver, AaronMcHale: "Notice: Array to string...

Status: Fixed » Closed (fixed)

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

markhalliwell’s picture

Status: Closed (fixed) » Needs work

This 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.

  • markcarver committed 6fffb80 on 8.x-3.x
    Revert "Issue #3085493 by AaronMcHale: "Notice: Array to string...

  • markcarver committed 5e49106 on 8.x-4.x
    Revert "Issue #3085493 by AaronMcHale: "Notice: Array to string...
mike421’s picture

Is 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.

  • markhalliwell committed 275da00 on 8.x-4.x
    Revert "Issue #3085493 by markcarver, AaronMcHale: "Notice: Array to...
  • markhalliwell committed 6fffb80 on 8.x-4.x
    Revert "Issue #3085493 by AaronMcHale: "Notice: Array to string...
  • markhalliwell committed 9c84eca on 8.x-4.x
    Issue #3085493 by markcarver, AaronMcHale: "Notice: Array to string...
  • markhalliwell committed c938ff8 on 8.x-4.x
    Issue #3085493 by AaronMcHale: "Notice: Array to string conversion" when...
shelane’s picture

Status: Needs work » Closed (won't fix)

This theme will not be supported for Bootstrap 4. See alternative themes for this support.