Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docroot/modules/custom/yukon_base/yukon_base.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@
* Main module file.
*/

/**
* Implements hook_form_alter().
*/
function yukon_base_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (!in_array($form_id, ['node_multi_step_page_form', 'node_multi_step_page_edit_form'])) {
return;
}

if (!isset($form['field_paragraphs']['widget'])) {
return;
}

$max_steps = 6;

$item_count = count(array_filter(
array_keys($form['field_paragraphs']['widget']),
fn($key) => is_int($key)
));

$form['field_paragraphs']['widget']['#cardinality'] = max($item_count, $max_steps);

if ($item_count >= $max_steps && isset($form['field_paragraphs']['widget']['add_more'])) {
$form['field_paragraphs']['widget']['add_more']['#access'] = FALSE;
}
}

/**
* Implements hook_views_data_alter().
*/
Expand Down
Loading