Problem/Motivation

The form IDs for the workflow transition add and edit forms get passed into the alter system with these IDs:

  • workflow_add-transition_form
  • workflow_edit-transition_form

The state add/edit forms have the same issue.

This makes targeting them with hook_form_FORM_ID_alter() impossible since the - is not converted to an underscore.

Proposed resolution

Change the dash to an underscore.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

jhedstrom created an issue. See original summary.

jhedstrom’s picture

Title: Workflow transtion add/edit form IDs have a '-' in them » Workflow state and transition add/edit form IDs have a '-' in them
Issue summary: View changes
jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new2.56 KB

I'm sure there's a more elegant fix that this, perhaps in the entity form routing system somewhere?

Status: Needs review » Needs work

The last submitted patch, 3: 2855428-03.patch, failed testing.

jhedstrom’s picture

So I think this would be an issue with any entity form route that has dashes in the link template name?

sam152’s picture

I wonder if the FormHandler should just replace hyphens with underscores when firing the hooks. Not sure if that would be an API change given technically new hooks would be firing.

himanshu-dixit’s picture

Status: Needs work » Needs review
timmillwood’s picture

StatusFileSize
new3.96 KB

Another option would be just changing the hyphens to underscores.

Status: Needs review » Needs work

The last submitted patch, 8: 2855428-8.patch, failed testing.

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB
new582 bytes

The convention elsewhere seems to be hyphens. Re suggestion in #3, making this part of EntityForm makes sense to me.

timmillwood’s picture

Component: content_moderation.module » entity system
Status: Needs review » Reviewed & tested by the community

So it looks like we're moving this out to be a standard entity system issue.

#10 seems fine to me, as long as test bot agrees.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: 2855428-10--test-only.patch, failed testing.

timmillwood’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC, only test-only patch failing.

himanshu-dixit’s picture

RTBC+1 @sam152 You are right. Just a piece of advise, try to upload test-only patch before the full patch, this way Status won't be set to Needs Work , I suppose.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 973e6b4 to 8.4.x and 3a18f95 to 8.3.x. Thanks!

Probably my mistake.

Committed to 8.3.x since workflow is experimental.

  • alexpott committed 973e6b4 on 8.4.x
    Issue #2855428 by Sam152, jhedstrom, timmillwood: Workflow state and...

  • alexpott committed 3a18f95 on 8.3.x
    Issue #2855428 by Sam152, jhedstrom, timmillwood: Workflow state and...

  • alexpott committed f572d83 on 8.4.x
    Revert "Issue #2855428 by Sam152, jhedstrom, timmillwood: Workflow state...

  • alexpott committed af359ce on 8.3.x
    Revert "Issue #2855428 by Sam152, jhedstrom, timmillwood: Workflow state...
alexpott’s picture

Status: Fixed » Needs work

I got this wrong - we shouldn't be changing the EntityForm implementation. That's unnecessarily risky - we should be doing the same as \Drupal\workflows\Form\WorkflowTransitionDeleteForm::getFormId(). Sorry for the false commit.

alexpott’s picture

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'workflow_transition_delete_form';
  }

Is what \Drupal\workflows\Form\WorkflowTransitionDeleteForm::getFormId() does

timmillwood’s picture

Component: entity system » content_moderation.module

@alexpott - You think we should just hardcode the form IDs?

I quite liked the idea in #10 as this solves the issue across the whole of core and adds a test for it too.

alexpott’s picture

@timmillwood I think it is an okay idea but I think that the fix is not 8.3.x because it is a behaviour change. So let's do the quick fix here and open a followup to discuss the entity form fix with the entity maintainers.

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new2.64 KB

Opened #2856645: Operations with hyphens should create entity form IDs with underscores.

This patch has form IDs consistent with the current defined ones and the form class names, however it's contrary to how the entity form would have generated the UI using the opperation. workflow_state_edit_form vs workflow_edit_state_form.

timmillwood’s picture

Status: Needs review » Reviewed & tested by the community

The patch looks good from the Workflow point of view.

Don't think we need a test for this.

jhedstrom’s picture

I added a follow-up to discuss the more global fix: #2856792: Possible to create entity forms with a '-' in the form ID

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed eb83216 to 8.4.x and 82f2015 to 8.3.x. Thanks!

As this is an experimental module backported to 8.3.x

  • alexpott committed eb83216 on 8.4.x
    Issue #2855428 by Sam152, jhedstrom, timmillwood: Workflow state and...

Status: Fixed » Closed (fixed)

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