0

I want to set hidden fields (permission by field) of a form in Drupal 8. The fields in the form have the names

field_pbf_municipality[0]['target_id']

field_pbf_municipality[0]['grant_public']

field_pbf_municipality[0]['grant_view']

field_pbf_municipality[0]['grant_update']

field_pbf_municipality[0]['grant_delete']

The permission by field “field_pbf_municipality” is a taxonomy term reference.

In my custom module I use the function hook_form_alter to call the function hook_form_validate:

$form['#validate'][] = hook_form_validate

Within the function hook_form_validate, I can set the field_pbf_municipality with statement

$form_state->setValue(‘field_pbf_municipality’, $term)

But I am not able to distinguish between, respectively to set target_id, grant_public, grant_view, grant_update and grant_delete individually. How to realise that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.