Exemple #1
0
 public function createComponentForm()
 {
     $form = new MyForm();
     $form->setTranslator($this->translator);
     //$form->addUpload('file', 'File')->addRule(FORM::MAX_FILE_SIZE, 'File is too big! Please, choose smaller one.', 3 * 1024 * 1024);
     $form->addText('name', 'Name')->addRule(Form::FILLED, 'Please, insert name of the file.');
     $form->addTextArea('description', 'Description');
     $form->addTextArea('note', 'Note');
     //$form->addSelect('user_id','Author',$this->system->getAccountsToSelect())->value = $this->user->isLoggedIn() ? $this->user->getIdentity()->id : NULL;
     $form->addCheckbox('visible', 'visible')->setDefaultValue(1);
     $form->addHidden('id');
     $form->onSuccess[] = array($this, 'saveItem');
     $form->addSubmit('save', 'Save');
     $form->addSubmit('saveBack', 'Save & back');
     return $form;
 }
 protected function createComponentEventForm()
 {
     $form = new MyForm();
     $form->renderStyle = MyForm::SEMANTIC;
     $form->setTranslator($this->presenter->translator);
     $form->getElementPrototype()->addAttributes(array('class' => ''));
     $form->addText('name', 'Event name')->setAttribute('class', 'input-xxlarge')->setOption('description', 'Název vaší akce. Ideální je kompletní název. Nepřidávejte žádné další údaje. Prosím, vyhněte se použití velkých písmen. Akce psané velkými písmeny budou upraveny. Děkujeme za pochopení.')->setRequired('Prosím, vyplňte název akce.');
     if ($this->user->isInRole('administrator')) {
         $form->addText('code', 'URL')->setOption('description', 'Pokud chceš editovat jak vypadá URL.');
     }
     $form->addTextArea('description', 'Event description')->setRequired('Prosím, popište o čem vaše akce je.')->getControlPrototype()->style("height: 500px");
     $form->addMultiSelect('categories', 'Categories', $this->context->createService('categories')->where('event', '1')->order('name')->fetchPairs('id', 'name'))->setAttribute('class', 'chzn')->setAttribute('placeholder', 'Prosím, vyberte kategorii')->setAttribute('data-placeholder', 'Prosím, vyberte kategorii')->setOption('description', 'Kategorie pomáhá uživatelům ve vyhledání vaší akce. Vyberte minálně jednu. Doporučujeme max. 3.')->setRequired('Kategorie musí být vyplněna, prosím vyberte minimálně jednu kategorii.');
     $places = $this->places->order('name')->fetchPairs('id', 'name');
     if (!$this->user->isInRole('administrator')) {
         $places = array(1 => 'Bez místa na PeknyDen.cz') + $places;
     }
     $form->addSelect('subject_id', 'Pořadatel - navázání akce k místu na PeknyDen.cz', $places)->setAttribute('class', 'chzn')->setAttribute('placeholder', 'Prosím, vyberte pořadatele akce.')->setAttribute('data-placeholder', 'Prosím, vyberte pořadatele akce.')->setPrompt('Prosím, vyberte pořadatele akce.')->setDefaultValue(1)->setRequired('Kategorie musí být vyplněna, prosím vyberte pořadatele akce.')->controlPrototype->onChange("submit();");
     if ($this->user->isInRole('administrator')) {
         $form->addCheckbox('rewrite', 'Přepiš data')->setDefaultValue(1);
         //			$form['subject_id']->setDefaultValue(1);
     }
     $form->addText('subject_name', 'Event place')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: U Štěpánků')->setRequired('Prosím, doplňte místo konání akce');
     $form->addSelect('shire_id', 'Shire', $this->context->createService('shires')->fetchPairs('id', 'name'))->setPrompt('Vyber kraj')->setAttribute('class', 'chzn')->setRequired('Prosím, doplňte prosím kraj, kde se akce koná');
     $form->addText('subject_city', 'City or village')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: Praha 3');
     $form->addText('subject_street', 'Street')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: Na Maninách 14');
     $form->addText('subject_locality_nickname', 'Locality for web', null, 127)->setAttribute('placeholder', 'např.: Žižkov');
     $form->addText('subject_zip', 'Zip')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: 323 00');
     $form->addText('subject_gps', 'GPS')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: 50°3\'44.151"N, 14°26\'10.500"E')->setRequired('GPS souřadnice jsou povinné. Jinak by vás nikdo nenašel.');
     $form->addText('subject_www', 'Web')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: http://peknyden.cz/');
     $form->addText('subject_facebook', 'Facebook Page', null, 127)->setAttribute('placeholder', 'např.: http://facebook.cz/peknydencz')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Facebook Page je vyplněna v nesprávném formátu.');
     $form->addText('subject_email', 'E-mail')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: jan.novy@seznam.cz')->setType('email')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'E-mailová adresa nemá správný tvar. Zkontrolujte prosím její zadání.');
     $form->addText('subject_phone', 'Phone number')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: 777 888 999');
     if ($this->contactEmail || $this->user->isInRole('administrator')) {
         $form->addText('contact_email', 'Contact e-mail')->setAttribute('class', 'input-xxlarge')->setAttribute('placeholder', 'např.: jan.novy@seznam.cz')->setOption('description', 'Kontaktní e-mail pro případné doplnění informací a zaslání potvrzení o zveřejnění akce (nezveřejňuje se na PeknyDen.cz)')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'E-mailová adresa nemá správný tvar. Zkontrolujte prosím její zadání.');
     }
     if ($this->notes || $this->user->isInRole('administrator')) {
         $form->addTextArea('notes', 'Notes')->setAttribute('class', 'input-xxlarge')->setOption('description', 'Zde vložte další poznámky k akci.');
     }
     $form->addHidden('id');
     $form->addHidden('user_id')->setDefaultValue($this->user->id);
     //$form->addHidden('type');
     $form->onSubmit[] = callback($this, 'beforeSave');
     if ($this->new) {
         $form->addSubmit('saveNew', 'Save and move to terms')->setAttribute('class', 'large green')->onClick[] = $this->saveDescription;
     } else {
         $form->addSubmit('save', 'Uložit popis akce')->setAttribute('class', 'large green')->onClick[] = $this->saveDescription;
         $form->addSubmit('saveBack', 'Uložit a zpět na akci')->setAttribute('class', 'black')->onClick[] = $this->saveDescription;
     }
     return $form;
 }