/** * Add custom HTML after the widget * * @param array $attributes * * @return string */ public function parse($attributes = null) { if (TL_MODE == 'BE') { $template = new BackendTemplate('be_wildcard'); $template->wildcard = '### PAGE BREAK ###'; return $template->parse(); } $manager = new MPFormsFormManager($this->pid); $this->canGoBack = !$manager->isFirstStep(); return parent::parse($attributes); }
/** * 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; }
<?php /** * mp_forms extension for Contao Open Source CMS * * @copyright Copyright (c) 2015-2016, terminal42 gmbh * @author terminal42 gmbh <*****@*****.**> * @license http://opensource.org/licenses/lgpl-3.0.html LGPL * @link https://github.com/terminal42/contao-mp_forms */ /** * Table tl_form_field */ $GLOBALS['TL_DCA']['tl_form_field']['config']['onsubmit_callback'][] = function ($dc) { $manager = new \MPFormsFormManager((int) $dc->activeRecord->pid); $manager->resetData(); }; $GLOBALS['TL_DCA']['tl_form_field']['palettes']['mp_form_pageswitch'] = '{type_legend},type,mp_forms_backButton,slabel,label;{image_legend:hide},imageSubmit;{expert_legend:hide},class,accesskey,tabindex;{template_legend:hide},customTpl'; $GLOBALS['TL_DCA']['tl_form_field']['fields']['mp_forms_backButton'] = ['label' => &$GLOBALS['TL_LANG']['tl_form_field']['mp_forms_backButton'], 'exclude' => true, 'inputType' => 'text', 'eval' => ['tl_class' => 'clr', 'maxlength' => 255, 'mandatory' => true], 'sql' => "varchar(255) NOT NULL default ''"];
/** * Redirect to step. * * @param MPFormsFormManager $manager * @param int $step */ private function redirectToStep(MPFormsFormManager $manager, $step) { \Controller::redirect($manager->getUrlForStep($step)); }