Rendering-Module

Folgende Module bieten die Möglichkeit Formular und Renderer im Backend auszuwählen.

yamlform.input.php

<?php
/**
 * @sly name        yamlform
 * @sly title       Formular
 * @sly description rendert ein in YAML definiertes Formular
 * @sly requires    [form_evaluation]
 */

if (class_exists('WV30_Form')) {
      throw new Exception('Please enable the form evaluation addOn.');
}

$value    = $values->get('form');
$forms    = WV30_Form::getForms();
$renderer = array();

foreach ($forms as $form) {
      foreach ($form->getRendererKeys() as $key) {
                $renderer[$form->getID().'/'.$key] = $form->getName().' ('.$key.')';
        }
}

$select = new sly_Form_Select_DropDown('form', 'Formular', $value, $renderer);
$form->add($select);

yamlform.output.php

<?php
/**
 * @sly name         yamlform
 * @sly title        Formular
 * @sly description  rendert ein in YAML definiertes Formular
 * @sly requires     [form_evaluation]
 */

if (!class_exists('WV30_Form')) {
        trigger_error('Form evaluation not enabled, cannot render form.', E_USER_WARNING);
}

$value = $values->get('form');
$value = explode('/', $value);

if (count($value) === 2) {
        $form = WV30_Form::getForm($value[0], false);

        if ($form) {
              if (sly_Core::isBackend()) {
                        print sly_html($form->getName()).' ('.$value[1].')';
                }
                else {
                      $form->doProcess();
                        print $form->render($value[1]);
                }
        }
}

Inhalt

Vorheriges Thema

Rendering

Nächstes Thema

Honeypots

Diese Seite