Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the form alter in data dictionary widget to only target node_data_form #4178

Merged
merged 2 commits into from
May 6, 2024

Conversation

janette
Copy link
Member

@janette janette commented May 6, 2024

Fixes error when trying to edit a user account.

InvalidArgumentException: Field field_data_type is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 583 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Drupal\Core\Entity\ContentEntityBase->get('field_data_type') (Line: 81)
data_dictionary_widget_form_alter(Array, Object, 'user_form') (Line: 545)

QA Steps

  • drush en data_dictionary_widget
  • drush uli
  • Visit /user/1/edit
  • Confirm you do not see the error above.
  • Visit /node/add/data?schema=data-dictionary
  • Confirm you see the new DD form

@janette janette changed the title Update the data dictionary form alter to only target node_data_form Update the form alter in data dictionary widget to only target node_data_form May 6, 2024
@@ -76,7 +76,7 @@ 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();

if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface) {
if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface && $form_id == 'node_data_form') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface & in_array($form_id, $target_form_ids)) {

Copy link
Contributor

@kaise-lafrai kaise-lafrai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some adjustments because I noticed that on edit form the theme was not being set correctly. Example: the UUID was not grayed out.

@kaise-lafrai
Copy link
Contributor

Looks good now. Waiting on pipeline to merge.

@kaise-lafrai kaise-lafrai self-requested a review May 6, 2024 15:14
@kaise-lafrai kaise-lafrai merged commit abecdc3 into 2.x May 6, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants