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.

CommentFileSizeAuthor
#8 workflow_3452716_8_undefined_key.patch7.46 KBjohnv

Comments

dcoppel created an issue. See original summary.

jaswinsingh’s picture

+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

dcoppel’s picture

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

ighosh’s picture

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!

dcoppel’s picture

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

johnv’s picture

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.

johnv’s picture

Title: Warning : Undefined array key "to_sid" dans Drupal\workflow\Element\WorkflowTransitionElement::copyFormValuesToTransition() (<myhomedir>/web/modules/contrib/workflow/src/Element/WorkflowTransitionElement.php ligne 356) » Warning : Undefined array key "to_sid" in WorkflowTransitionElement::copyFormValuesToTransition() ligne 356
johnv’s picture

Status: Active » Needs review
StatusFileSize
new7.46 KB

Please check attached patch.

dcoppel’s picture

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.

johnv’s picture

Issue summary: View changes

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

johnv’s picture

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

dcoppel’s picture

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

johnv’s picture

Assigned: Unassigned » 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...
johnv’s picture

Title: Warning : Undefined array key "to_sid" in WorkflowTransitionElement::copyFormValuesToTransition() ligne 356 » Warning : Undefined array key "to_sid" in WorkflowTransitionElement::copyFormValuesToTransition() line 356 when using Ajax button from other field
Status: Needs review » Fixed
dcoppel’s picture

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

iaacristobal’s picture

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. I also did a build test and it says "Patch failed to apply"

johnv’s picture

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

tikaszvince’s picture

Hi @johnv,

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

johnv’s picture

rfmarcelino’s picture

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

johnv’s picture

@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?

Status: Fixed » Closed (fixed)

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

dcoppel’s picture

Unfortunately, I have the same issue as @rfmarcelino :

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 dans Drupal\Core\Field\WidgetBase->errorElement() (ligne 646 de /var/www/drupalextranet/web/core/lib/Drupal/Core/Field/WidgetBase.php)

I check in 'Manage form display' of the workflow. I think I changed nothing in this part but I saw in field "To state" that the value is set to "Inline Entity Form - Simple".

Let me know if you need more information to help.
Regards,

dcoppel’s picture

I saw in 'Manage form display' that three field added between v. 1.7 and 1.8 : To state, Timestamp and Log message that was activating.
I don't know if there is a link with the error...

johnv’s picture

Let us continue this conversation in #3458984: TypeError: 'WidgetBase::errorElement(): Argument #1 ($element) must be of type array, null given, called in WidgetBase.php'.
Please post your error over there (to preserve your user name) with precise use case and modules.

@rfmarcelino, I tested with Entity Brouwser and IEF installed, but in the EntityBrowser widget, I see an empty field 'browser'.
when creating a new node, I get the error:

TypeError: key(): Argument #1 ($array) must be of type array, null given in key() (line 424 of modules\contrib\entity_browser\src\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget.php).

pdcarto’s picture

This issue is marked "Closed (fixed)" but it has not been tagged into a release. That forces anyone who wants to use this fix to use a dev branch of this module which, by definition, is not recommended for production sites.

The remaining open related issue is weakly described (no steps to reproduce, unable to be reproduced by some commenters) and should not, in my opinion, block getting this work out to a tagged release.

@johnv, would you be willing to get this merged/tagged into a release?