Ejemplo n.º 1
0
<?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 ''"];
Ejemplo n.º 2
0
 /**
  * Store the submitted data into the session and redirect to the next step
  * unless it's the last.
  *
  * @param array $submitted
  * @param array $labels
  * @param $fieldsOrForm
  * @param $formOrFields
  */
 public function prepareFormData(&$submitted, &$labels, $fieldsOrForm, $formOrFields)
 {
     // Compat with Contao 4 and 3.5
     $form = $fieldsOrForm instanceof \Form ? $fieldsOrForm : $formOrFields;
     $manager = new MPFormsFormManager($form->id);
     // Don't do anything if not valid
     if (!$manager->isValidFormFieldCombination()) {
         return;
     }
     // Store data in session
     $manager->storeData($submitted, $labels, (array) $_SESSION['FILES']);
     // Submit form
     if ($manager->isLastStep() && 'continue' === $submitted['mp_form_pageswitch']) {
         $allData = $manager->getDataOfAllSteps();
         // Replace data by reference and then return so the default Contao
         // routine kicks in
         $submitted = $allData['submitted'];
         $labels = $allData['labels'];
         $_SESSION['FILES'] = $allData['files'];
         // Clear session
         $manager->resetData();
         return;
     } else {
         // Make sure the Contao form data session handling doesn't do
         // anything at all while we're on a multipage form
         $_SESSION['FORM_DATA'] = [];
     }
     $this->redirectToStep($manager, $manager->getNextStep());
 }