Resolve #3506267 "Changing page title"
2 unresolved threads
Closes #3506267
Merge request reports
Activity
added 1 commit
added 13 commits
Toggle commit list36 36 'data' => $data, 37 37 'data_hash' => \hash('xxh64', \serialize($data)), 38 38 'langcode' => $entity instanceof TranslatableInterface ? $entity->language()->getId() : NULL, 39 // @todo Update label from incoming entity data once it exists. 40 'label' => (string) $entity->label(), 39 'label' => self::getLabelToSave($entity, $data), 41 40 ]; 42 41 $this->getTempStore()->set($key, $auto_save_data); 43 42 $this->cacheTagsInvalidator->invalidateTags([self::CACHE_TAG]); 44 43 } 45 44 45 public static function getLabelToSave(EntityInterface $entity, array $data): string { 46 return empty($data['entity_form_fields']) 47 ? (string) $entity->label() 48 : (string) $data['entity_form_fields'][sprintf("%s[0][value]", $entity->getEntityType()->getKey('label'))]; 49 } - Comment on lines +46 to +49
this doesn't deal with the case where the value is missing, how about this instead?
47 return empty($data['entity_form_fields']) 48 ? (string) $entity->label() 49 : (string) $data['entity_form_fields'][sprintf("%s[0][value]", $entity->getEntityType()->getKey('label'))]; 50 } 47 $key = \sprintf("%s[0][value]", $entity->getEntityType()->getKey('label')); 48 return $data['entity_form_fields'][$key] ?? (string) $entity->label(); 49 } I added this change but I don't it works as I would have expected. If the title field is empty in the form, then the "Review X changes" title is also missing. I don't think this makes sense. I think we should fallback to saved entity label when
$data['entity_form_fields'][$key]
is an empty string
added 14 commits
-
61991cfb...9892b97a - 13 commits from branch
project:0.x
- 338fe2e7 - Merge branch '0.x' into 3506267-changing-page-title
-
61991cfb...9892b97a - 13 commits from branch
added 1 commit
- b9c7470c - fallback to saved title when form field is empty
76 76 ], 77 77 ], 78 78 'model' => [], 79 'entity_form_fields' => [], 79 'entity_form_fields' => [ 80 // Ensure that if the form title is empty, the saved title will be 81 // returned. 82 'title[0][value]' => '', - Comment on lines +80 to +82
I confirm locally the test will fail without the latest commit !654 (b9c7470c) to
\Drupal\experience_builder\AutoSave\AutoSaveManager::getLabelToSave
Edited by Ted Bowman
Please register or sign in to reply