/** * Builds the navigation array items. * * @return array */ private function buildNavigationItems() { $manager = new MPFormsFormManager($this->form); $steps = range(0, $manager->getNumberOfSteps() - 1); $items = []; $firstFailingStep = $manager->validateSteps(); foreach ($steps as $step) { // Check if step can be accessed $cantBeAccessed = true !== $firstFailingStep && $step > $firstFailingStep; // Only active if current step or step cannot be accessed because of // previous steps $isActive = $step === $manager->getCurrentStep() || $cantBeAccessed; $items[] = ['isActive' => $isActive, 'class' => 'step_' . $step . ($cantBeAccessed ? ' forbidden' : ''), 'href' => $manager->getUrlForStep($step), 'title' => $manager->getLabelForStep($step), 'link' => $manager->getLabelForStep($step), 'nofollow' => true]; } \Haste\Generator\RowClass::withKey('class')->addFirstLast()->addEvenOdd()->applyTo($items); return $items; }
/** * Redirect to step. * * @param MPFormsFormManager $manager * @param int $step */ private function redirectToStep(MPFormsFormManager $manager, $step) { \Controller::redirect($manager->getUrlForStep($step)); }