Skip to content
Snippets Groups Projects

Resolve #3506267 "Changing page title"

2 unresolved threads

Closes #3506267

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
36 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?

    Suggested change
    Applied
    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

  • pushed up the change

  • Please register or sign in to reply
  • Ted Bowman added 14 commits

    added 14 commits

    Compare with previous version

  • Ted Bowman resolved all threads

    resolved all threads

  • Ted Bowman added 1 commit

    added 1 commit

    • 885255bb - Handle empty title in form field

    Compare with previous version

  • Ted Bowman added 1 commit

    added 1 commit

    • b9c7470c - fallback to saved title when form field is empty

    Compare with previous version

  • Ted Bowman added 1 commit

    added 1 commit

    • 92918370 - add test coverage for empty title string

    Compare with previous version

  • Ted Bowman
  • 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]' => '',
  • Ted Bowman approved this merge request

    approved this merge request

  • merged

  • Please register or sign in to reply
    Loading