Loading src/Form/EntityFormSteps.php +9 −21 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ namespace Drupal\entity_form_steps\Form; use Drupal\Component\Utility\SortArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Render\Markup; use Drupal\Core\Url; Loading Loading @@ -103,6 +102,15 @@ class EntityFormSteps { static::setAccess($stepName, $form); } } elseif (isset($form['#fieldgroups'][$stepName])) { // Limit validation errors to elements on the current step. if (!isset($form['actions']['submit']['#limit_validation_errors'])) { $form['actions']['submit']['#limit_validation_errors'] = []; } foreach ($form['#fieldgroups'][$stepName]->children as $key) { $form['actions']['submit']['#limit_validation_errors'][] = [$key]; } } } if ($title = Markup::create($step['format_settings'][$entity->isNew() ? 'add_label' : 'edit_label'])) { $form['#title'] = $title; Loading Loading @@ -206,27 +214,7 @@ class EntityFormSteps { static::setAccess($element, $form); } $form[$element]['#access'] = FALSE; // Recursively unset required property on element. Typically, disabling // access is enough to limit validation errors. Complex field types // like image and media still throw errors with access disabled. static::unsetRequired($form[$element]); } } } /** * Recursively unset required property an element. * * @param array $element * The element. */ public static function unsetRequired(array &$element): void { if (isset($element['#required'])) { $element['#required'] = FALSE; } foreach (Element::children($element) as $child) { static::unsetRequired($element[$child]); } } Loading Loading
src/Form/EntityFormSteps.php +9 −21 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ namespace Drupal\entity_form_steps\Form; use Drupal\Component\Utility\SortArray; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Render\Markup; use Drupal\Core\Url; Loading Loading @@ -103,6 +102,15 @@ class EntityFormSteps { static::setAccess($stepName, $form); } } elseif (isset($form['#fieldgroups'][$stepName])) { // Limit validation errors to elements on the current step. if (!isset($form['actions']['submit']['#limit_validation_errors'])) { $form['actions']['submit']['#limit_validation_errors'] = []; } foreach ($form['#fieldgroups'][$stepName]->children as $key) { $form['actions']['submit']['#limit_validation_errors'][] = [$key]; } } } if ($title = Markup::create($step['format_settings'][$entity->isNew() ? 'add_label' : 'edit_label'])) { $form['#title'] = $title; Loading Loading @@ -206,27 +214,7 @@ class EntityFormSteps { static::setAccess($element, $form); } $form[$element]['#access'] = FALSE; // Recursively unset required property on element. Typically, disabling // access is enough to limit validation errors. Complex field types // like image and media still throw errors with access disabled. static::unsetRequired($form[$element]); } } } /** * Recursively unset required property an element. * * @param array $element * The element. */ public static function unsetRequired(array &$element): void { if (isset($element['#required'])) { $element['#required'] = FALSE; } foreach (Element::children($element) as $child) { static::unsetRequired($element[$child]); } } Loading