예제 #1
0
 public function createComponentToolsForm()
 {
     $form = new \soundake\helpers\MyForm();
     $form->setTranslator($this->presenter->translator);
     $form->addCheckbox('visible', 'Visible')->setDefaultValue(1);
     $form->addCheckbox('approved', 'Approved')->setDefaultValue(1);
     $form->addCheckbox('reviewed', 'Reviewed')->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');
     $categories = new \Model\Categories('admintools');
     $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');
     $form->addSelect('user_id', 'Owner', $this->context->createServiceUsers()->fetchPairs('id', 'email'))->setPrompt('---')->setAttribute('class', 'input-xxlarge chzn');
     $form->addSubmit('save', 'Save')->onClick[] = $this->savePlace;
     $form->addHidden('id');
     return $form;
 }
예제 #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;
 }
예제 #3
0
 public function createComponentSubjectForm()
 {
     $form = new AppForm();
     $form->setTranslator($this->translator);
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'div class="well"';
     $renderer->wrappers['pair']['container'] = 'div  class="control-group"';
     $renderer->wrappers['label']['container'] = 'div class="control-label"';
     $renderer->wrappers['control']['container'] = 'div class="controls"';
     $renderer->wrappers['error']['container'] = 'ul class="alert alert-error"';
     $form->getElementPrototype()->addAttributes(array('class' => 'form-horizontal'));
     $form->addText('name', 'Name', null, 255)->setRequired('Name must be filled.')->setAttribute('placeholder', 'Write name of your subject')->getControlPrototype()->class('span6');
     $form->addText('street', 'Street', null, 127)->setRequired('Street must bu filled.')->setAttribute('placeholder', 'Write street when your subject is located')->getControlPrototype()->class('span6');
     $form->addSelect('locality_id', 'Locality', $this->system->getLocalitiesToSelect());
     $form->addText('locality_alt', 'New locality');
     $form['locality_id']->setPrompt("--- Choose your option ---")->setOption('description', 'Nenašli jste v seznamu svoji lokalitu? Napište její název a kraj, kde se nachází do následujícího pole.')->setAttribute('placeholder', 'Choose locality')->getControlPrototype()->class('span6 chzn');
     $form['locality_alt']->setAttribute('placeholder', 'Write new locality')->getControlPrototype()->class('span6');
     $form['locality_id']->addConditionOn($form['locality_alt'], ~Form::FILLED, TRUE)->addRule(FORM::FILLED, 'Locality must be filled');
     $form['locality_alt']->addConditionOn($form['locality_id'], ~Form::FILLED, TRUE)->addRule(FORM::FILLED, 'Alternative locality');
     //$form->addRequestButton('addlocality', 'Add new locality', ':Admin:System:Localities:add');
     //$form['addlocality']->getControlPrototype()->class('btn_add');
     $form->addText('locality_nickname', 'Local name', null, 127)->setAttribute('placeholder', 'Write local name of your locality')->getControlPrototype()->class('span6');
     $form->addText('zip', 'Zip', null, 10)->setOption('description', 'Např.: 12345')->setAttribute('placeholder', 'Write ZIP code')->getControlPrototype()->class('span6');
     $form->addText('map_coords', 'Map coordinates', null, 255)->setOption('description', 'Například: "Loc: 50°5\'42.12"N,14°29\'14.75"E". Vyhledejte na http://www.mapy.cz vaši adresu a vpravo klikněte na odkaz GPS')->addRule(FORM::FILLED, 'Map coordinates must be filled.')->setAttribute('placeholder', 'Paste here coordinates of your subject')->getControlPrototype()->class('span6');
     $form->addText('web', 'Website', null, 127)->setAttribute('placeholder', 'Have your subject website? Put it in here')->setOption('description', 'http://domain.tld/foo')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Website je vyplněna v nesprávném formátu.');
     $form['web']->getControlPrototype()->class('span6');
     $form->addText('facebook', 'Facebook Page', null, 127)->setAttribute('placeholder', 'Do you have Facebook Page? Put here its URL')->setOption('description', 'http://domain.tld/foo')->addCondition(FORM::FILLED)->addRule(FORM::URL, 'Facebook Page je vyplněna v nesprávném formátu.');
     $form['facebook']->getControlPrototype()->class('span6');
     $form->addText('email', 'E-mail', null, 127)->setAttribute('placeholder', 'Write contact e-mail or e-mail for reservations')->setOption('description', '*****@*****.**')->addCondition(FORM::FILLED)->addRule(FORM::EMAIL, 'E-mail je vyplněn v nesprávném formátu.');
     $form['email']->getControlPrototype()->class('span6');
     $form->addText('phone', 'Phone', null, 127)->setAttribute('placeholder', 'Write contact phone number or phone number for reservations')->setOption('description', 'Například: +420 123 456 789 nebo 123 456 789')->addCondition(Form::FILLED)->addRule(FORM::REGEXP, 'Telephone number is not valid.', '/^(\\+420)? ?\\d{3} ?\\d{3} ?\\d{3}$/');
     $form['phone']->getControlPrototype()->class('span6');
     $form->addTextArea('description', 'Description')->setAttribute('placeholder', 'Please, describe your venue. It sels.')->getControlPrototype()->class('span6');
     $categories = new \Model\Categories($this->ns);
     $items = $categories->getGlobalCategoriesArray('subject');
     $form->addMultiSelect('categories', 'Categories', $items)->setAttribute('data-placeholder', 'Choose one category. Or more.')->getControlPrototype()->class('span6 chzn');
     $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')->setAttribute('placeholder', 'When do you have open a close.')->getControlPrototype()->class('span6');
     $form->addTextArea('pricelist', 'Prices')->setAttribute('placeholder', 'Write some prices')->getControlPrototype()->class('span6');
     $form->addCheckbox('stroller', 'Stroller')->setDefaultValue(0);
     $form->addTextArea('notice', 'Notice for administrator')->setOption('description', 'Chcete-li nám ke zpracování vašeho profilu na PeknyDen.cz něco sdělit.')->getControlPrototype()->class('span9');
     $form->addHidden('user_id', $this->user->getId());
     $form->addHidden('visible');
     $form->addSubmit('save', 'Save Subject')->getControlPrototype()->class('btn btn-primary');
     $form->addSubmit('cancel', 'Cancel')->setValidationScope(FALSE)->onClick[] = array($this, 'cancelClicked');
     $form['cancel']->getControlPrototype()->class('btn btn-grey btn-small');
     $form->onSuccess[] = array($this, 'saveSubject');
     return $form;
 }
예제 #4
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;
 }