Warning : Undefined array key "to_sid" in WorkflowTransitionElement::copyFormValuesToTransition() line 356 when using Ajax button from other field

Created on 5 June 2024, 23 days ago
Updated 17 June 2024, 11 days ago

Since I have installed the new version of module (1.8) and when I try to add a file in a field file in my form an error message appears:

Error: content has no workflow attached. The data is not saved.

I specify that this form contains a field of type workflow state.
Then I tried to save my form values by validate it and it is not possible as an error displayed : This value can't be null

Can you fix this please?
Thanks a lot for your help.

🐛 Bug report
Status

Fixed

Version

1.8

Component

Workflow Field API

Created by

🇫🇷France dcoppel

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

Comments & Activities

  • Issue created by @dcoppel
  • +1 Facing similar error, I have an eck entity referenced in the user entity, where the eck entity is created on the user register form using IEF. This entity has workflow already attached to it, After using the latest version 1.8, I am getting this error when saving the user register form This value should not be null

  • 🇫🇷France dcoppel

    I have IEF fields too in my form like you Jaswinsingh !

  • 🇮🇳India ishanghosh27

    Hi @dcoppel @Jaswinsingh, I have a fresh Drupal site. Could you tell me the steps to reproduce this issue so I can work on the fix? Thanks!

  • 🇫🇷France dcoppel

    Hi @IGhosh,
    Thanks to help us !

    You can try to create a node type with a file field and a field type of workflow state.
    Then you can create an other node type with only two text fields.
    Then after installed IEF module, you can add in the first node type a field that refer to the the second node type (to add the fsecond form in the first one).
    Then try to add a node base on first node type to see if it works.
    Thanks for your help.
    Regards

  • 🇳🇱Netherlands johnv

    I now see 2 use cases:

    First:
    - have a node type with Workflow and File
    - create a node, add a file, save the node. Erro occurs because the 'triggering element' is not the save button, but "field_file_0_upload_button". After saving again, node seems to be saved correctly.
    - the error does not occur is no file is uploaded.

    Second:
    - have a node type with Workflow and IEF.
    - Did not test, but may have the same test script and result.

  • 🇳🇱Netherlands johnv
  • Status changed to Needs review 21 days ago
  • 🇳🇱Netherlands johnv

    Please check attached patch.

  • 🇫🇷France dcoppel

    Hi @johnv,
    Thanks for your post.
    I was intalled your patch but I have the same result.

    1- Loading file : An error displayed after file load (Error: content has no workflow attached. The data is not saved.), this error is just up to file field but the file is loading fine.

    2- I can submit the form for a new node but I can't submit the form when modifying the node : general form error message appears : This value can't be null.
    Thanks for your help.

  • 🇳🇱Netherlands johnv

    Thanks,
    do you use select/radios in workflow difeinition, or action button/dropbutton?

  • 🇳🇱Netherlands johnv

    And your file field is attached to the entity/node itself, not to the workflow?

  • 🇫🇷France dcoppel

    Hi,
    I use actions button in my workflow. And my field file is attached directly to my entity/node.
    Let me know if you need more informations.
    Thanks for your help.
    Regards

  • Assigned to johnv
  • 🇳🇱Netherlands johnv

    Working on this. I think i found a Solution.
    Problem was a test on isNew() Which is True after adding/removing the file.

    Cleaning up the code now.

    • johnv committed 7dc13c54 on 8.x-1.x
      Issue #3452716: Warning : Undefined array key to_sid in...
  • Status changed to Fixed 15 days ago
  • 🇳🇱Netherlands johnv
  • 🇫🇷France dcoppel

    Hi @johnv,
    I just install and test your last commit and the two problems I had seems to be correct now !
    Thanks a lot !

  • 🇵🇭Philippines iaacristobal Manila

    I'm encountering an issue applying the patch. It's returning this error on my end:

    patch: **** Only garbage was found in the patch input.
    
       Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2024-06-07/workflow_3452716_8_undefined_key.patch

    I applied this using composer-patches.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 14 days ago
    Patch Failed to Apply
  • 🇳🇱Netherlands johnv

    There is no patch provider for this against 1.8 version. Please use dev version.

  • 🇭🇺Hungary tikaszvince

    Hi @johnv,

    Any chance of creating a new release with these fixes in the next few days?

  • 🇳🇱Netherlands johnv

    Yex, I will this week.
    I am waiting for response on 🐛 TypeError: WorkflowTransitionElement::copyFormValuesToTransition() (line 356) Needs review

  • 🇵🇹Portugal rfmarcelino

    I'm unsure if this will help, but let me share my experience.
    for context, I have a node type using a workflow and I'm using the 'Workflow transition form' widget and a field with Entity Browser.

    While creating a new node, and running Ajax (opening entity Browser) I get:
    Error: content has no workflow attached. The data is not saved.

    I tried to install the dev version but started getting this error even without touching the form:

    TypeError: Drupal\Core\Field\WidgetBase::errorElement(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/web/core/lib/Drupal/Core/Field/WidgetBase.php on line 580 in Drupal\Core\Field\WidgetBase->errorElement() (line 646 of /var/www/html/web/core/lib/Drupal/Core/Field/WidgetBase.php)

    For now, I locked it to 1.7 in composer.json
    "drupal/workflow": "1.7",
    and it works well.

    In 1.7 and prior $form["field_wf_status"]["widget"][0]["workflow_transition"]["#value"]) was set and in 1.8 is NULL

  • 🇳🇱Netherlands johnv

    @rfmarcelino, Thanks for your response.
    Regarding the error 'Argument #1 ($element)', did you change anything in the settings for 'Manage form display' of the workflow?

Production build 0.69.0 2024