Beispiel #1
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;
 }
Beispiel #2
0
 public function createComponentForm()
 {
     $form = new \RequestButton\RequestButtonReceiver();
     $form->setTranslator($this->translator);
     $form->addGroup('User');
     /*
     		  if ($this->user->isAllowed('users','edit')) {
     		  $form->addText('login', 'Login:'******'username', 'Login:'******'Prosím, vlož username');
     //}
     $form->addText('name', 'Name:')->addRule(Form::FILLED, 'Prosím, vlož jméno');
     $form->addText('surname', 'Surname:')->addRule(Form::FILLED, 'Prosím, vlož příjmení');
     $form->addSelect('role', 'Role:', $this->items->getRolesToSelect())->addRule(Form::FILLED, 'Please, select right user role.');
     $form->addCheckbox('active', 'Active:');
     $form->addSelect('country_id', 'Country:', $this->system->getCountriesToSelect())->addRule(Form::FILLED, 'Prosím, vlož stát')->setValue(208);
     $form->addRadioList('sex', 'Sex:', $this->system->getSexToSelect())->addRule(Form::FILLED, 'Prosím, vyber pohlaví');
     $form->addGroup('Additional data');
     $form->addText('email', 'E-mail:')->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'E-mail is not valid');
     $form->addText('homepage', 'Homepage:')->addCondition(Form::FILLED)->addRule(Form::URL, 'Homepage is not valid');
     $form->addText('telephone', 'telephone:');
     $form->addText('street', 'Street:');
     $form->addText('city', 'City:');
     $form->addText('zip', 'Zip:');
     $form->addText('icq', 'ICQ:');
     $form->addText('aim', 'AIM:');
     $form->addText('skype', 'Skype:');
     $form->addText('jabber', 'Jabber:');
     $form->addText('birthday', 'Birthday:');
     $form->addTextArea('description', 'Description:');
     $form->addGroup('Password');
     $form->addPassword('heslokreslo', 'Password:'******'password1', 'Password again:')->addConditionOn($form['heslokreslo'], Form::FILLED, TRUE)->addRule(Form::FILLED, 'Prosím, vlož heslo znovu');
     /*
      if ($this->user->isAllowed('users')) {
      $this['form']->addPassword('heslokreslo', 'Heslo:');
      } else {
      $this['form']->addPassword('password', 'Heslo:')->addRule(Form::FILLED, 'Prosím, vlož heslo');
      }
      $this['form']->addPassword('password1', 'Heslo znovu:')
      ->addConditionOn($this['form']['heslokreslo'], Form::FILLED, TRUE)
      ->addRule(Form::FILLED, 'Prosím, vlož heslo znovu');
     */
     /*
      if ($this->getView() == 'add')
      {
      $form->addSubmit('add', 'Save & Add next');
      $form->addSubmit('leave', 'Save & Leave');
      } else {
      $form->addHidden('id');
      $form->addSubmit('leave', 'Save & Leave');
      $form->addSubmit('add', 'Save & Add new');
      }
     
     
      $form->addSubmit('save', 'Save');
      $form->addSubmit('cancel', 'Cancel')->setValidationScope(FALSE)->onClick[] = 'CancelClicked';
      $form['cancel']->getControlPrototype()->class('cancel');
     */
     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;
 }
Beispiel #3
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;
 }