Hi,
firstable, thanks for the huge job done on this module which is absolutely great and must have feature for Drupal.
I try to customize the element's configuration forms by hiding the fields I do not need. I can do it for basically all the desired fields/details components, but unfortunately, I have an issue with the element attributes (classes, style and element custom attribute (YAML)) form element.
I would like to alter the display of this component by hiding the style textfield, but it's impossible to target it through the following hooks :
- hook_form_webform_ui_element_form_alter
- hook_preprocess_form_element
- hook_preprocess_webform_element_attributes
I can see the form Element add his own Preprocess methods inside the form element itself, so maybe it is not "hookable", or I'm just missing something.
Tank you in advance for your help.
Comments
Comment #2
jrockowitz commentedUse the below code to hide elements from global configuration and element settings.
Comment #3
grumpydev74Thank you @jrockowitz, but I already tried that solution from the documentation and it does not allow to do what I want.
This way, I can't hide only the element attributes style field as the webform element because it is created in is own preprocess Method from it's own class. So I can't reach the sub keys through the hooks given in the exemple.
Obviously I'm able to hide the complete fieldset "element attributes", but it's not my goal here, I just want to hide the field "element attributes style" included in this fieldset.
Finally, I succeeded to do it using the hook_preprocess_form_element, and by adding the hidden class on the desired elements. But I'm still assuming I could be better ti be able to manage fields visibility from the hook_form_webform_ui_element_form_alter to keep a consistency. Just my opinion by the way.
Comment #4
jrockowitz commentedI think I will need to add support for '#attributes__access': FALSE.
An immediate workaround is to add a '#process' hook and alter the $element['#attributes'];
Comment #5
jrockowitz commentedI just reviewed \Drupal\webform\Element\WebformElementAttributes and something like
$element['wrapper_attributes']['#attributes__access'] = FALSE;should work as expected.Comment #6
grumpydev74Thank you @jrockowitz, this quick fix will do the trick.
Comment #7
jrockowitz commentedI think that is the long term solution.