How may I be able to limit a webform component visibility by logged user role? In Drupal 7, this was possible with webform_component_roles module but there is no version for Drupal 8.

Thank you.

1 Answer 1


When creating/editing a field, scroll down to ELEMENT ACCESS. There you can set all the limitations based on roles.

If you use YML you can use something like:

    - administrator
    - authenticated
    - authenticated

Finally, if you want to change the accessibility of the webform, check the Access tab (admin/structure/webform/manage/FORM_NAME/access).

  • Thank you, that helps but want I wanted to do was to disable a component if the role is not Administrator. Can I do that? Commented May 24, 2017 at 16:29
  • You can hide it. Or you wan to be visible but not editable? If so you can use hook_form_alter.
    – Ismini
    Commented May 24, 2017 at 16:36
  • I want it hidden if possible. I have a checkbox that checked disables a textarea element, when I hide the checkbox for the User role the textarea element that was disabled turns enabled and editable... May I use that hook directly on a theme.module file? Commented May 24, 2017 at 16:40
  • Below the Element Access you will find the CONDITIONAL LOGIC. There, you can set up your conditions based on other fields. The only problem I found here is that you shouldn't require the hidden field as even if it's hidden, on submit, expecting to have a value.
    – Ismini
    Commented May 25, 2017 at 8:21
  • That's my problem.. I don't know how to solve it. I don't necesseray have to use the button to disable, I just want disabled elements when the user logged role is not administrator. Can I set that through the Elements YAML file? Thank you! Commented May 25, 2017 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.