示例#1
0
 public function createComponentForm()
 {
     $form = new \RequestButton\RequestButtonReceiver();
     $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->addCheckbox('lock', 'locked');
     $form->addHidden('backlink');
     $form->onSuccess[] = array($this, 'saveItem');
     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');
     }
     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;
 }