Skip to content

Commit

Permalink
HPC-9987: Keep supporting legacy labels
Browse files Browse the repository at this point in the history
  • Loading branch information
berliner committed Dec 24, 2024
1 parent 20c24da commit be4d1ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ public function buildForm($element, FormStateInterface $form_state) {
$element['label']['#access'] = !$attachment_select_mode;

if ($attachment) {
// Move legacy labels into the data point and hide default label for
// configuration items.
if (!empty($element['label']['#default_value'])) {
$data_point['label'] = $element['label']['#default_value'];
}
$element['label']['#access'] = FALSE;
$element['label']['#default_value'] = '';
$element['label']['#value'] = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function buildForm($element, FormStateInterface $form_state) {
$element = parent::buildForm($element, $form_state);
$data_point = $this->getSubmittedValue($element, $form_state, 'data_point');

// Move legacy labels into the data point and hide default label for
// configuration items.
if (!empty($element['label']['#default_value'])) {
$data_point['label'] = $element['label']['#default_value'];
}
$element['label']['#access'] = FALSE;
$element['label']['#default_value'] = '';
$element['label']['#value'] = '';
Expand All @@ -55,8 +62,6 @@ public function buildForm($element, FormStateInterface $form_state) {
/** @var \Drupal\ghi_plans\ApiObjects\AttachmentPrototype\AttachmentPrototype $attachment_prototype */
$attachment_prototype = $configuration['attachment_prototype'];

$data_point = $this->getSubmittedValue($element, $form_state, 'data_point');

$element['data_point'] = [
'#type' => 'data_point',
'#element_context' => $this->getContext(),
Expand Down

0 comments on commit be4d1ce

Please sign in to comment.