Skip to content

Commit

Permalink
Update the form alter in data dictionary widget to only target node_d…
Browse files Browse the repository at this point in the history
…ata_form (#4178)
  • Loading branch information
janette committed May 6, 2024
1 parent 6061fbe commit abecdc3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/data_dictionary_widget/data_dictionary_widget.module
Expand Up @@ -75,8 +75,9 @@ function data_dictionary_widget__data_dictionary_data_type_checker($context) {
*/
function data_dictionary_widget_form_alter(&$form, &$form_state, $form_id) {
$formObject = $form_state->getFormObject();
$target_form_ids = ['node_data_edit_form', 'node_data_form'];

if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface) {
if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface && in_array($form_id, $target_form_ids)) {
$entity = $formObject->getEntity();
$data_type = $entity->get('field_data_type')->value;
if (isset($form["field_json_metadata"]["widget"][0]["dictionary_fields"])) {
Expand All @@ -93,9 +94,7 @@ function data_dictionary_widget_form_alter(&$form, &$form_state, $form_id) {
$form['actions']['submit']['#submit'][] = 'data_dictionary_widget_form_submit';
}
}
}

if ($form_id == 'node_data_edit_form' || $form_id == 'node_data_form') {
$form['#validate'][] = 'data_dictionary_widget_validate_unique_identifier';
$current_fields = !empty($form["field_json_metadata"]["widget"][0]["dictionary_fields"]["current_fields"]) ? $form["field_json_metadata"]["widget"][0]["dictionary_fields"]["current_fields"] : NULL;

Expand Down

0 comments on commit abecdc3

Please sign in to comment.