Drupal Webform: Hide required field, if a field in parent node contains ...

Hide required field 'usa_tax_id', if the field 'event_number' in parent node looks like 'DE-123abc-2024':

            function MY_MODULE_form_alter(&$form, &$form_state, $form_id)

                $node = $form_state->getFormObject()->getEntity();
				
                $event_number = $node->get('event_number')->value ?? '';

                if( preg_match("#^D.*2024$#simU", $event_number) ) {

                    $form['elements']['usa_tax_id']['#access'] = FALSE;

                }
            }

File: web/module/custom/MY_MODULE/MY_MODULE.module

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare