Skip to content
Snippets Groups Projects
Commit f73de6fb authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-5880: updating the states for media and adding allowed value function for media width

parent b38e9c62
No related branches found
No related tags found
3 merge requests!284Feature/istwcms 5880 ebremner banners above,!274Draft: ISTWCMS-5551: fixing office hours display,!260Feature/istwcms 5668 a5kulkar rename references to publications
...@@ -589,6 +589,41 @@ function uw_cfg_common_preprocess_node(&$variables) { ...@@ -589,6 +589,41 @@ function uw_cfg_common_preprocess_node(&$variables) {
} }
} }
/**
* Get the layout builder styles as options.
*
* @param \Drupal\field\Entity\FieldStorageConfig $definition
* The field definition.
* @param \Drupal\Core\Entity\ContentEntityInterface|null $entity
* The entity being created if applicable.
* @param bool $cacheable
* Boolean indicating if the results are cacheable.
*
* @return array
* An array of possible key and value options.
*
* @see options_allowed_values()
*/
function _uw_cfg_common_get_layout_builder_styles (
FieldStorageConfig $definition,
ContentEntityInterface $entity = NULL,
$cacheable
) {
// Get all the styles for sections.
$all_styles = _layout_builder_styles_retrieve_by_type('section');
// Array of options.
$options = [];
// Step through each style and get the info.
foreach ($all_styles as $style) {
$options[$style->id()] = $style->label();
}
return $options;
}
/** /**
* Implements hook_page_attachments(). * Implements hook_page_attachments().
*/ */
...@@ -925,7 +960,7 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, ...@@ -925,7 +960,7 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
]; ];
// Set the states for the banner. // Set the states for the banner.
$form['field_uw_banner']['#states'] = [ $form['group_banner']['#states'] = [
'visible' => [ 'visible' => [
[ [
'select[name="field_uw_type_of_media"]' => [ 'select[name="field_uw_type_of_media"]' => [
...@@ -936,12 +971,15 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, ...@@ -936,12 +971,15 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
]; ];
// Set the states for the banner settings. // Set the states for the banner settings.
$form['group_banner_settings']['#states'] = [ $form['field_uw_media_width']['#states'] = [
'visible' => [ 'visible' => [
[ [
'select[name="field_uw_type_of_media"]' => [ 'select[name="field_uw_type_of_media"]' => [
['value' => 'banner'], ['value' => 'banner'],
], ],
'select[name="field_uw_text_overlay_style"]' => [
['value' => 'full-width'],
],
], ],
], ],
]; ];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment