Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We use the following pattern in f.e. WorkflowDefaultWidget:
// Step 1: use the Element.
$element['#default_value'] = $transition;
$element += WorkflowTransitionElement::transitionElement($element, $form_state, $form);
// Step 2: use the Form, in order to get extra/attached fields.
$entity_form_builder = \Drupal::getContainer()->get('entity.form_builder');
$workflow_form = $entity_form_builder->getForm($transition, 'add');
Where the last line also calls TransitionElement.
This is not fine, since this bad performance, and the 'default' form_id is Always overridden.
Comment | File | Size | Author |
---|---|---|---|
#6 | workflow-remove_the_rewriting_of_the_form_id-2926094-6.patch | 1.8 KB | robertom |
Comments
Comment #3
johnvI see no way to avoid calling the Element first, then WorkflowTransitionForm. The latter has too many subelements, it is impossible to determine which ones to keep or to discard.
Comment #6
robertom CreditAttribution: robertom at bmeme commentedI do not know if this is the root cause of my problem, but I need to remove the WorkflowTransitionForm::getFormId() method to not have the problem I will describe below.
I have a view block with a list of transitions and the links to edit them...
links are in this format:
/workflow_transition/13/edit?destination=/group/7/projects/1
/workflow_transition/17/edit?destination=/group/7/projects/1
/workflow_transition/18/edit?destination=/group/7/projects/1
and open the workflow_transition form in a modal
when I try to save (from the modal) instead to save the form and go to destination, I get redirected to the page with the form edit (outside the modal) where the data have not been modified. Saving from this last page the data are correctly modified.
If I remove the WorkflowTransitionForm::getFormId() method, everything works as I expect (the form in the modal saves the data) and sends me to the destination page indicated in the url.
attached the patch that I use for remove the method, but should not be considered as a patch for resolving this issue
Comment #7
johnvOK,
perhaps, we can do the latter part conditionally, after executing
Comment #8
johnvChanged to Bug , as per #6
Comment #9
johnvin #2899025-57: Attached field type 'file' not working on WorkflowTransition, I removed the unique ID.
Please test dev version.
I guess this solves your problem, If not please reopen.
Comment #10
johnvComment #11
johnvComment #27
johnvWe now have 3 possible options:
Option 1: call transitionElement() directly.
Option 2: call WorkflowTransitionForm() directly.
Option 3: call WorkflowDefaultWidget via NodeFormDisplay.