Skip to content

Commit

Permalink
updated help text and change labels
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Dec 17, 2024
1 parent 7c31c61 commit 24efbaa
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ id: node.landing_page.field_landing_page_hero_theme
field_name: field_landing_page_hero_theme
entity_type: node
bundle: landing_page
label: Here image theme
description: 'If your hero image is mostly dark, apply the dark theme. This changes how the page title is displayed.'
required: false
label: Page title display style
description: 'By default the page title will display in the site’s primary colour. If you choose ‘Reverse blocked text’ the heading and introduction text will be white with a coloured block behind the text (the site’s ‘accent contrast’ and ‘accent alternate’ colours). See <a href="https://ripple.sdp.vic.gov.au/design-system/components/header">Ripple header page to understand the header </a>component design.'
required: true
translatable: false
default_value: { }
default_value_callback: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ settings:
allowed_values:
-
value: dark
label: Dark
label: Reverse blocked text
-
value: light
label: Light
label: Default
allowed_values_function: ''
module: options
locked: false
Expand Down
22 changes: 22 additions & 0 deletions modules/tide_landing_page/tide_landing_page.install
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,25 @@ function tide_landing_page_update_10107() {
$tide_update_helper = \Drupal::service('tide_core.entity_update_helper');
$tide_update_helper->revert('field_config', 'paragraph.key_journeys.field_paragraph_title');
}

/**
* Set field `field_landing_page_hero_theme` to mandatory.
*/
function tide_landing_page_update_10108() {
$bundles = [
'landing_page',
'publication',
'publication_page',
];

foreach ($bundles as $bundle) {
$field = FieldConfig::loadByName('node', $bundle, 'field_landing_page_hero_theme');
if (!empty($field)) {
$field->setLabel('Page title display style');
$field->setRequired(TRUE);
$field->setDefaultValue('default');
$field->setDescription('By default the page title will display in the site’s primary colour. If you choose ‘Reverse blocked text’ the heading and introduction text will be white with a coloured block behind the text (the site’s ‘accent contrast’ and ‘accent alternate’ colours). See <a href="https://ripple.sdp.vic.gov.au/design-system/components/header">Ripple header page to understand the header </a>component design.');
$field->save();
}
}
}
30 changes: 25 additions & 5 deletions modules/tide_landing_page/tide_landing_page.module
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ function tide_landing_page_entity_bundle_create($entity_type_id, $bundle) {
* Implements hook_form_BASE_FORM_ID_alter().
*/
function tide_landing_page_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$bundles = [
'landing_page',
'publication',
'publication_page',
];

foreach ($bundles as $bundle) {
$field = FieldConfig::loadByName('node', $bundle, 'field_landing_page_hero_theme');
// if (!empty($field)) {
// $field->setLabel('Page title display style');
// $field->setRequired(TRUE);
// $field->setDefaultValue('light');
// $field->save();
// }
dump($field);
}


if (in_array($form_id, [
'node_landing_page_form',
'node_landing_page_edit_form',
Expand Down Expand Up @@ -118,10 +136,10 @@ function tide_landing_page_form_node_form_alter(&$form, FormStateInterface $form
unset($form['field_show_hero_image_caption']);
}
// Move Hero Image theme to Hero Image field group.
if (isset($form['field_landing_page_hero_theme']) && isset($form['field_landing_page_hero_image']['widget'])) {
$form['field_landing_page_hero_image']['widget']['field_landing_page_hero_theme'] = $form['field_landing_page_hero_theme'];
unset($form['field_landing_page_hero_theme']);
}
// if (isset($form['field_landing_page_hero_theme']) && isset($form['field_landing_page_hero_image']['widget'])) {
// $form['field_landing_page_hero_image']['widget']['field_landing_page_hero_theme'] = $form['field_landing_page_hero_theme'];
// unset($form['field_landing_page_hero_theme']);
// }

// @todo the below block needs to be in a proper widget alter.
if (isset($form['field_landing_page_component']['widget'][0])) {
Expand Down Expand Up @@ -407,12 +425,14 @@ function _tide_landing_page_form_node_form_process(array $form, FormStateInterfa
],
];

$form['field_landing_page_hero_image']['#states']['visible'] = [
$form['field_landing_page_hero_theme']['#states']['disabled'] = [
':input[name="_header_style_options"]' => [
['value' => 'default'],
['value' => 'fullwidth'],
['value' => 'cta'],
],
];

$form['field_graphical_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => ['value' => 'corner'],
];
Expand Down

0 comments on commit 24efbaa

Please sign in to comment.