- Issue created by @plopesc
- @plopesc opened merge request.
- Status changed to Needs review
over 1 year ago 11:08am 25 April 2023 - 🇳🇱Netherlands neograph734 Netherlands
The field name and transition id are passed to the form builder, so you can recover the transition. I have always used below approach:
$build_info = $form_state->getBuildInfo(); [$field_name, $transition_id] = $build_info['args']; $state_item = $build_info['callback_object']->getEntity()->get($field_name)->first(); /** @var \Drupal\state_machine\Plugin\Workflow\WorkflowTransition $transition */ $transition = $state_item->getWorkflow()->getTransition($transition_id);
But I must say that your method looks much better. It can then be accessed via
$form_state->getFormObject()->getTransition()
? - Status changed to RTBC
over 1 year ago 6:41pm 25 April 2023 - 🇳🇱Netherlands neograph734 Netherlands
Confirming this works and it is a much better method than what I used.
-
jsacksick →
committed b6c3a060 on 8.x-1.x authored by
plopesc →
Issue #3351567 by plopesc: Add method to retrieve the transition in "...
-
jsacksick →
committed b6c3a060 on 8.x-1.x authored by
plopesc →
- Status changed to Fixed
over 1 year ago 6:27am 16 May 2023 Automatically closed - issue fixed for 2 weeks with no activity.