Esempio n. 1
0
 protected function createComponentForm()
 {
     $form = new \RequestButton\RequestButtonReceiver();
     $form->setTranslator($this->translator);
     $form->addGroup('Basics');
     $form->addText('name', 'Name')->setAttribute('maxlength', 255)->addRule(FORM::FILLED, 'Name must be filled');
     $form->addSelect('account_id', 'Author', $this->system->getAccountsToSelect())->addRule(FORM::FILLED, 'Accounts must be filled')->setAttribute('class', 'chzn')->setDefaultValue($this->user->id);
     $form->addRequestButton('adduser', 'Add new author', ':Admin:Users:Default:add');
     $form['adduser']->getControlPrototype()->class('btn_add');
     $form->addTextArea('perex', 'Perex')->addRule(FORM::FILLED, 'Perex must be filled')->getControlPrototype()->class('texyla');
     foreach ($this->context->createServiceFiles()->where('isImage', '1')->where('isnull(deleted)')->order('created DESC') as $item) {
         //$el = \Nette\Utils\Html::el('option')->value($item->id)->setText($this->presenter->getHttpRequest()->url->baseUrl . 'image/crop-100x100/' . $item->code);
         $el = \Nette\Utils\Html::el('option')->value($item->id)->setText($item->code);
         $arr[$item->id] = $el;
     }
     $form->addSelect('file_id', 'File:', $arr)->setPrompt('Choose image')->setAttribute('class', 'eggs');
     //		foreach ($this->context->createServiceFiles()->where('isImage', '1')->where('isnull(deleted)')->where('visible','1')->limit(100)->order('created DESC') as $item) {
     //			$el = \Nette\Utils\Html::el('option')->value($item->id)->setText($item->name)->data(array('imagesrc' => $this->presenter->getHttpRequest()->url->baseUrl . 'image/crop-40x40/' . $item->code, 'description' => $item->description));
     //			//if($key == $data->doprava_id)
     //			//$el->selected(TRUE);
     //			$arr[$item->id] = $el;
     //		}
     //
     //		$form->addSelect('file_id', 'File:', $arr)
     //			->setPrompt('Choose image')->setAttribute('class', 'ddslick');
     //		$form->addSelect('file_id', 'File', $this->context->createServiceFiles()->where('isImage','1')->where('isnull(deleted)')->fetchPairs('id', 'name'))->setPrompt('Choose image');
     $form->addTextArea('body', 'Body')->addRule(FORM::FILLED, 'Body must be filled')->getControlPrototype()->class('texyla');
     $form->addTextArea('conclusion', 'Conclusion')->setAttribute('cols', 40)->setAttribute('rows', 5)->getControlPrototype()->class('texyla');
     $form->addText('published', 'Published')->setAttribute('size', 10)->getControlPrototype()->class('datetimepicker');
     $form->addGroup('Hidden');
     $form->addTextArea('notes', 'Notes')->setAttribute('cols', 40)->setAttribute('rows', 5)->getControlPrototype();
     $form->addTextArea('keywords', 'Keywords')->setAttribute('cols', 40)->setAttribute('rows', 5)->setOption('description', 'Zadejte klíčová slova či spojení oddělená čárkou.');
     $form->addCheckbox('is_visible', 'Visible')->setDefaultValue(1);
     $form->addCheckbox('ad', 'Recommended');
     if (!$this->isRequestButton) {
         if ($this->getView() == 'add') {
             $form->addSubmit('add', 'Save & Add next')->getControlPrototype()->class('primary');
             $form->addSubmit('leave', 'Save & Leave');
         } else {
             $form->addHidden('id');
             $form->addSubmit('leave', 'Save & Leave')->getControlPrototype()->class('primary');
             $form->addSubmit('add', 'Save & Add new');
         }
         $form->addSubmit('save', 'Save');
         $form->addRequestButtonBack('back', 'Cancel & Back')->getControlPrototype();
         $form->addSubmit('cancel', 'Cancel')->setValidationScope(FALSE)->onClick[] = 'CancelClicked';
         $form['cancel']->getControlPrototype()->class('cancel');
     } else {
         $form->addSubmit('save', 'Save')->getControlPrototype()->class('primary');
         $form->addRequestButtonBack('back', 'Cancel')->getControlPrototype()->class('cancel');
     }
     $form->onSuccess[] = array($this, 'saveItem');
     return $form;
 }
Esempio n. 2
0
 protected function createComponentForm()
 {
     $form = new \RequestButton\RequestButtonReceiver();
     $form->setTranslator($this->translator);
     $form->addGroup('Basics');
     $form->addText('name', 'Name', null, 255)->addRule(Form::FILLED, 'Name must be filled');
     $form->addSelect('locality_id', 'Locality', $this->system->getLocalitiesToSelect())->addRule(FORM::FILLED, 'Locality must be filled')->setPrompt("---");
     $form->addRequestButton('addlocality', 'Add new locality', ':Admin:System:Localities:add');
     $form['addlocality']->getControlPrototype()->class('btn_add');
     $form->addText('locality_alt', 'New locality from user', null, 255);
     $form->addText('street', 'Street', null, 127);
     $form->addText('locality_nickname', 'Locality for web', null, 127);
     $form->addText('zip', 'Zip', null, 10)->setOption('description', 'Např.: 12345');
     $form->addText('web', 'Website', null, 127)->setOption('description', 'http://domain.tld/foo')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Website je vyplněna v nesprávném formátu.');
     $form->addText('facebook', 'Facebook Page', null, 127)->setOption('description', 'http://domain.tld/foo')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Facebook Page je vyplněna v nesprávném formátu.');
     $form->addText('email', 'E-mail', null, 127)->setOption('description', '*****@*****.**')->addCondition(FORM::FILLED)->addRule(FORM::EMAIL, 'E-mail je vyplněn v nesprávném formátu.');
     $form->addText('phone', 'Phone', null, 127)->setOption('description', '+420 123 456 789, +420 123 456 789');
     $form->addText('map_coords', 'Map coordinates', null, 255)->setOption('description', 'Loc: 50°5\'42.12"N,14°29\'14.75"E')->addRule(FORM::FILLED, 'Map coordinates must be filled.');
     $form->addTextArea('description', 'Description')->getControlPrototype()->class('texyla');
     $categories = new \Model\Categories($this->ns);
     $items = $categories->getGlobalCategoriesArray('subject', true);
     $form->addMultiSelect('categories', 'Categories', $items);
     $form->addGroup('Settings');
     $form->addText('age_min', 'Min. age', null, 10)->addCondition(FORM::FILLED)->addRule(FORM::INTEGER, 'Věk musí být uveden v celých letech.');
     $form->addText('age_max', 'Max. age', null, 10)->addCondition(FORM::FILLED)->addRule(FORM::INTEGER, 'Věk musí být uveden v celých letech.');
     $form->addTextArea('openhours', 'Opening hours');
     $form->addTextArea('pricelist', 'Prices');
     $form->addCheckbox('stroller', 'Stroller')->setDefaultValue(0);
     $form->addCheckbox('visible', 'Visible')->setDefaultValue(1);
     $form->addCheckbox('show_in_catalogue', 'Show in catalogue')->setDefaultValue(1);
     $form->addCheckbox('show_in_calendar', 'Show in calendar')->setDefaultValue(1);
     $form->addCheckbox('approved', 'Approved')->setDefaultValue(1);
     $form->addTextArea('notice', 'Notice');
     $form->addGroup('Recommended');
     $form->addCheckbox('ad', 'Recommended');
     $form->addCheckbox('ad_onhomepage', 'On homepage');
     $form->addText('ad_name', 'Alternative name (40 chars)');
     $form->addText('ad_description', 'Alternative description');
     $form->addSelect('ad_category', 'Only in category', $categories->getGlobalCategoriesArray('subject', null, false))->setPrompt('---');
     $form->addSelect('ad_shire', 'Only in shire', $this->system->getShiresToSelect('name', false))->setPrompt('---');
     $form->addGroup('Buttons :)');
     if (!$this->isRequestButton) {
         if ($this->getView() == 'add') {
             $form->addSubmit('add', 'Save & Add next')->getControlPrototype()->class('primary');
             $form->addSubmit('leave', 'Save & Leave');
         } else {
             $form->addHidden('id');
             $form->addSubmit('leave', 'Save & Leave')->getControlPrototype()->class('primary');
             $form->addSubmit('add', 'Save & Add new');
         }
         $form->addSubmit('save', 'Save');
         $form->addRequestButtonBack('back', 'Cancel & Back')->getControlPrototype();
         //todo K cemu to je? Je to potreba?
         $form->addSubmit('cancel', 'Cancel')->setValidationScope(FALSE)->onClick[] = 'CancelClicked';
         $form['cancel']->getControlPrototype()->class('cancel');
     } else {
         $form->addSubmit('save', 'Save')->getControlPrototype()->class('primary');
         $form->addRequestButtonBack('back', 'Cancel')->getControlPrototype()->class('cancel');
     }
     $form->onSuccess[] = array($this, 'saveItem');
     return $form;
 }
Esempio n. 3
0
 protected function createComponentForm()
 {
     $form = new \RequestButton\RequestButtonReceiver();
     $form->renderStyle = MyForm::SEMANTIC;
     $form->setTranslator($this->translator);
     $form->addText('name', 'Place name')->addRule(Form::FILLED, 'Name must be filled')->setAttribute('placeholder', 'Name of place');
     $form->addTextArea('description', 'Description')->setAttribute('rows', 300)->setRequired('Popište, co se na vašim místě najde.')->getControlPrototype()->style('height: 500px;');
     $categories = new \Model\Categories($this->ns);
     $items = $categories->getGlobalCategoriesArray('subject', true);
     $form->addMultiSelect('categories', 'Categories', $items)->setRequired('Zařaďte své místo do nějaké kategorie pro lepší nalezení.')->setAttribute('class', 'chzn')->setAttribute('data-placeholder', 'Vyberte kategorii')->addCondition(\Nette\Forms\Form::FILLED, 'Dej tam kategorii');
     $form->addSelect('locality_id', 'Locality', $this->context->createServiceLocalities()->select('locality.id, concat(locality.name, " / ", shire.name) AS title')->order('title')->fetchPairs('id', 'title'))->setPrompt("---")->setAttribute('class', 'chzn');
     $form->addRequestButton('addlocality', 'Add new locality', ':Admin:System:Localities:add');
     $form['addlocality']->getControlPrototype()->class('btn_add');
     $form->addCheckbox('locality_alt_toggle', 'Add new locality')->setDefaultValue(FALSE)->addCondition(Form::EQUAL, TRUE)->toggle("locality_alt");
     $form->addText('locality_alt', 'New locality from user', null, 255)->addConditionOn($form['locality_id'], Form::BLANK)->addRule(Form::FILLED, 'Vyberte lokalitu nebo zadejte novou.');
     $form['locality_id']->addConditionOn($form['locality_alt'], FORM::BLANK)->addRule(FORM::FILLED, 'Locality must be filled');
     $form->addText('map_coords', 'Map coordinates', null, 255)->setAttribute('placeholder', '49°49\'55.074"N, 18°16\'36.995"E')->addRule(FORM::FILLED, 'Map coordinates must be filled.');
     $form->addText('street', 'Street and number', null, 127)->setAttribute('placeholder', 'Na Maninách 14');
     $form->addText('locality_nickname', 'Locality for web', null, 127)->setAttribute('placeholder', 'Žižkov');
     $form->addText('zip', 'Zip', null, 10)->setOption('description', 'Např.: 12345')->setAttribute('placeholder', '13000');
     $form->addCheckbox('scope_all', 'Působnost v celé ČR.')->setOption('description', 'Zaškrtněte působíte-li na území celé ČR.');
     $form->addText('web', 'Website', null, 127)->setOption('description', 'http://domain.tld/foo')->setAttribute('placeholder', 'http://peknyden.cz/')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Website je vyplněna v nesprávném formátu.');
     $form->addText('facebook', 'Facebook Page', null, 127)->setOption('description', 'http://domain.tld/foo')->setAttribute('placeholder', 'http://facebook.cz/peknydencz')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Facebook Page je vyplněna v nesprávném formátu.');
     $form->addText('email', 'E-mail', null, 127)->setOption('description', '*****@*****.**')->setAttribute('placeholder', '*****@*****.**')->addCondition(FORM::FILLED)->addRule(FORM::EMAIL, 'E-mail je vyplněn v nesprávném formátu.');
     $form->addText('phone', 'Phone', null, 127)->setOption('description', '+420 123 456 789, +420 123 456 789')->setAttribute('placeholder', '800 110 100');
     $form->addText('age_min', 'Min. age', null, 10)->addCondition(FORM::FILLED)->addRule(FORM::INTEGER, 'Věk musí být uveden v celých letech.');
     $form->addText('age_max', 'Max. age', null, 10)->addCondition(FORM::FILLED)->addRule(FORM::INTEGER, 'Věk musí být uveden v celých letech.');
     $form->addTextArea('pricelist', 'Prices');
     $form->addTextArea('openhours', 'Opening hours');
     $form->addCheckbox('stroller', 'Stroller')->setDefaultValue(0);
     $form->addCheckbox('wheelchair_access', 'Wheelchair Access')->setDefaultValue(0);
     $form->addCheckbox('nonsmoking', 'Nonsmoking')->setDefaultValue(0);
     if ($this->user->isInRole('administrator')) {
         $form->addCheckbox('visible', 'Visible')->setDefaultValue(0);
     } else {
         $form->addCheckbox('visible', 'Visible')->setDefaultValue(1);
     }
     $form->addTextArea('notice', 'Notice');
     if ($this->user->isInRole('administrator')) {
         $form->addSelect('user_id', 'Owner', $this->context->createServiceUsers()->fetchPairs('id', 'email'))->setPrompt('---')->setAttribute('class', 'input-xxlarge chzn');
         $form->addCheckbox('approved', 'Approved')->setDefaultValue(1);
         $form->addCheckbox('show_in_catalogue', 'Show in catalogue')->setDefaultValue(1);
         $form->addCheckbox('show_in_calendar', 'Show in calendar')->setDefaultValue(1);
         $form->addCheckbox('ad', 'Recommended');
         $form->addCheckbox('ad_onhomepage', 'On homepage');
         $form->addText('ad_name', 'Alternative name (40 chars)');
         $form->addText('ad_description', 'Alternative description');
         $form->addSelect('ad_category', 'Only in category', $categories->getGlobalCategoriesArray('subject', null, false))->setPrompt('---')->setAttribute('class', 'input-xxlarge chzn');
         $form->addSelect('ad_shire', 'Only in shire', $this->context->createServiceShires()->fetchPairs('id', 'name'))->setPrompt('---')->setAttribute('class', 'input-xxlarge chzn');
     } else {
         $form->addHidden('approved', 'Approved')->setDefaultValue(0);
         $form->addHidden('show_in_catalogue', 'Show in catalogue')->setDefaultValue(1);
         $form->addHidden('show_in_calendar', 'Show in calendar')->setDefaultValue(1);
     }
     if (!$this->isRequestButton) {
         $form->addSubmit('save', 'Save place')->onClick[] = callback($this, 'savePlace');
         $form->addSubmit('saveNew', 'Save place')->onClick[] = callback($this, 'savePlace');
         $form->addSubmit('saveBack', 'Save & Back')->onClick[] = callback($this, 'savePlace');
     } else {
         //$form->addSubmit('save', 'Save')->getControlPrototype()->class('primary');
         $form->addRequestButtonBack('back', 'Cancel')->getControlPrototype()->class('cancel');
     }
     $form->addHidden('id');
     $form->addHidden('code');
     return $form;
 }