Can't assign a default value

Created on 19 June 2024, 10 days ago
Updated 24 June 2024, 5 days ago

I have a reference entity field with a default value assigned and after updating from Tagify 1.2.11 to the latest version it stopped working (I get an error and the default value is not added).

Because of the error, Tagify stopped working altogether for any other field using it.

If I revert back to it works as expected. Playing with the different versions, it looks like the bug was introduced in version 1.2.12.

🐛 Bug report
Status

Closed: cannot reproduce

Version

1.2

Component

Code

Created by

🇬🇧United Kingdom Ok4p1 Glasgow

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Ok4p1
  • 🇪🇸Spain gxleano Cáceres

    Hi Ok4p1,

    We have updated Tagify form element in 1.2.18, see: https://www.drupal.org/project/tagify/issues/3411891 Add support for custom form-element supporting entity_reference Needs review

    So, if you want to use the latest version, you might update your custom form elements.

  • 🇪🇸Spain gxleano Cáceres

    BTW, #default_value should be an array of entities, you could check an example from the latest version here: https://www.drupal.org/project/tagify/issues/3411891#comment-15588899 Add support for custom form-element supporting entity_reference Needs review

  • 🇬🇧United Kingdom Ok4p1 Glasgow

    Hello, thank you for getting back to me. The part I don't get is that this is not a custom element, it is just an entity reference referencing a taxonomy term. Shouldn't that work out-of-the-box without having to customize it, like it did on 1.2.11?

    I tried with 1.2.18 and the issue is still there.

  • 🇪🇸Spain gxleano Cáceres

    Thanks for the reply, now it is clearer.

    Could you paste here the error that you are getting, please?

  • 🇪🇸Spain gxleano Cáceres
  • Status changed to Closed: cannot reproduce 6 days ago
  • 🇪🇸Spain gxleano Cáceres
  • 🇬🇧United Kingdom Ok4p1 Glasgow

    Apologies, I wasn't able to replicate it either on a clean install, so it must be something about my codebase :(

  • 🇬🇧United Kingdom Ok4p1 Glasgow

    If anyone else faces this issue, my problem was the syntax used to disable the field programmatically so users could not change the default value (something that worked with 1.2.11).

    Breaks: $form['field_page_type']['widget']['#attributes'] = ['disabled' => 'disabled'];
    Works: $form['field_page_type']['widget']['#attributes']['disabled'] = 'disabled';

Production build 0.69.0 2024