Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace FrontModule\Forms\NewSurvey;
- use Nette\Application\UI\Form,
- Nette\InvalidStateException;
- class NewQuestionForm extends Form
- {
- public function __construct()
- {
- parent::__construct();
- $this->getElementPrototype()->addClass('ajax');
- $this->addProtection('Prosím odešlete formulář znovu (vypršela platnost bezpečnostního tokenu).');
- $this->addText('nameCopy', 'Název dotazníku:');
- $survey = $this->presenter->model->survey;
- $questions = $this->addDynamic('questions', function ($question) use ($survey) {
- $this->addTextArea('question', 'Otázka:', 50, 10)
- ->setRequired('Musíte vyplnit text otázky.');
- $this->addSelect('type', 'Typ:', array('0' => 'prvni', '1' => 'Druha'))
- ->setPrompt('-- Vyberte --');
- $this->addSelect('format', 'Formát otázky:', $survey->getSurveyPairs())
- ->setPrompt('-- Vyberte --');
- });
- $questions->addSubmit('add', 'Přidat otázku');
- $this->onSuccess[] = array($this, 'submitted');
- }
- public function submitted(Form $form)
- {
- try {
- $values = $form->values;
- var_dump($values);
- exit;
- $this->presenter->redirect(':Front:NewSurvey:edit', array('id' => $survey));
- } catch (InvalidStateException $e) {
- $this->presenter->flashMessage($e->getMessage(), 'warning');
- $this->presenter->redirect('this');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment