- Issue created by @dabley
- 🇳🇱Netherlands johnv
Indeed, the 'internal' interface was changed, in order to re-use the standard 'Manage Form Display' settings of the Workflow subfields.
Your changes are correct.
Please check workflow.api.php file for more useage.
also, $transition = $form_state->{$field_name} ->getTransition(); was introduced. Hi @johnv, thanks for your quick response, and for confirming that my solution to my first problem is correct. But for my second problem, I dont have a solution. When I call
$form_state->getValue([<parentfield>])
, I get back an array which includes all the fields on
the form, but excluding field_state, which holds my workflow. In v1.7, field_state was there alongside all the other fields, but with v1.8, it is simply gone.I looked in workflow.api.php file, but I couldn't see anything that looked relevant.
Where can I find my field_state inside $form_state?
- 🇳🇱Netherlands johnv
Indeed, nothing in $form_state. Strange.
You can check $form[$field_name]. Hi @johnv, yes, the workflow field (field_state) does appear in the $form array - but this is the value originally shown on the edit form, not the value after the user has made changes.
I have now found the workflow field in the $form_state - but it is not where I'd expected. Instead of
$to_state = $form_state->getValue([<parentfield>, 'field_state', 'to_sid', 0, 'target_id']);
it is in
$to_state = $form_state->getValue(['to_sid', 0, 'target_id']);
So, I can look up the value. But I also want to be able to update the value in my validation routine. However, when I try:
$form_state->setValue(['to_sid', 0, 'target_id'], $new_value);
I find that the value in the entity doesnt actually get updated.Not only that, but simply trying to change the workflow state using the drop-down on the edit page (rather than my custom code), the field also does not get updated.
This looks like a bug to me.