protected function createComponentAddEdit($name) { $roles[0] = ' '; $mroles = new RolesModel(); $rows = $mroles->getTreeValues(); foreach ($rows as $key => $row) { // function array_merge does't work correctly with integer indexes // manual array merge $roles[$key] = $row; } $form = new AppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; //$form->addGroup('Add'); $form->addText('name', 'Name', 30)->addRule(Form::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()"); $form->addText('key_name', 'Key', 30)->addRule(Form::FILLED, 'You have to fill key.'); $form->addSelect('parent_id', 'Parent', $roles, 15); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(Form::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSubmit[] = array($this, 'addEditOnFormSubmitted'); }
public function createComponentContactForm() { $form = new AppForm(); $form->addText("name", "Jméno"); $form->addText("email", "E-mail")->setRequired('Vyplňte, prosím, správně svůj email.')->addRule(Form::EMAIL, 'Vyplňte, prosím, správně svůj email.'); $form->addTextArea("text", "Zpráva")->setRequired('Vyplňte, prosím, svou zprávu.'); $form->addSubmit("submit1", "Odeslat"); //$form->addProtection(); //sends cookie ... wtf? $form->onSuccess[] = callback($this, 'contactFormSubmitted'); return $form; }
protected function createComponentHomeForm($name) { $form = new AppForm(); $form->addTextArea('text', 'Text')->addRule(Form::FILLED, "Bez textu zůstane úvodní strana prázdná")->getControlPrototype()->style = 'width: 685px; height: 370px'; $form->addHidden('id'); $dataSource = dibi::query('SELECT id, text FROM [options] WHERE [name]=%s', 'home')->fetch(); if ($dataSource != null) { $form->setDefaults($dataSource); } $form->addSubmit('ok', 'Uložit')->onClick[] = array($this, 'saveClicked'); return $form; }
protected function createComponentAddEdit($class) { $form = new AppForm($this, $class); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; $form->addText('class', 'class', 30)->addRule(Form::FILLED, 'You have to fill class.'); //$form->addGroup('Edit'); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(Form::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSubmit[] = array($this, 'addEditOnFormSubmitted'); }
protected function createComponentAddEdit($name) { $form = new AppForm($this, $name); $renderer = $form->getRenderer(); $renderer->wrappers['label']['suffix'] = ':'; if (ACL_PROG_MODE) { $form->addText('name', 'Name', 30)->addRule(Form::FILLED, 'You have to fill name.')->getControlPrototype()->onChange("create_key()"); } else { $form->addText('name', 'Name', 30)->addRule(Form::FILLED, 'You have to fill name.'); } //$form->addGroup('Edit'); $form->addText('key_name', 'Key', 30)->setDisabled(ACL_PROG_MODE ? false : true); $form->addTextArea('comment', 'Comment', 40, 4)->addRule(Form::MAX_LENGTH, 'Comment must be at least %d characters.', 250); if ($this->getAction() == 'add') { $form->addSubmit('add', 'Add'); } else { $form->addSubmit('edit', 'Edit'); } $form->onSubmit[] = array($this, 'addEditOnFormSubmitted'); }
public function createComponent($name) { switch ($name) { case 'manageStatusesForm': $form = new AppForm($this, $name); $statuses = array(0 => __('–––')); foreach (mapper::order_statuses()->findAll() as $_) { $statuses[$_->getId()] = $_->getName() . ($_->getInitial() ? ' ✱' : ''); } $form->addSelect('id', __('Status:'), $statuses)->skipFirst(); $form['id']->addRule(Form::FILLED); $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManageStatusesFormEdit'); break; case 'statusAddForm': case 'statusEditForm': $prefix_len = strlen('status'); $action = substr($name, $prefix_len); $action = substr($action, 0, strlen($action) - 4); $form = new AppForm($this, $name); if (substr($name, strlen($name) - 8) === 'EditForm') { $form->addHidden('id'); } $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry status name.')); $form->addCheckbox('initial', __('initial for orders')); $form->addSubmit('ok', '✔ ' . __($action)); $form->onSubmit[] = array($this, 'on' . substr($name, 0, strlen($name) - 4) . 'Submit'); break; case 'managePaymentTypesForm': $form = new AppForm($this, $name); $types = array(0 => __('–––')); foreach (mapper::order_payment_types()->findAll() as $_) { $types[$_->getId()] = $_->getName(); } $form->addSelect('id', __('Payment type:'), $types)->skipFirst(); $form['id']->addRule(Form::FILLED); $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManagePaymentTypesFormEdit'); break; case 'manageDeliveryTypesForm': $form = new AppForm($this, $name); $types = array(0 => __('–––')); foreach (mapper::order_delivery_types()->findAll() as $_) { $types[$_->getId()] = $_->getName(); } $form->addSelect('id', __('Delivery type:'), $types)->skipFirst(); $form['id']->addRule(Form::FILLED); $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onManageDeliveryTypesFormEdit'); break; case 'paymentTypeAddForm': case 'paymentTypeEditForm': $prefix_len = strlen('paymentType'); case 'deliveryTypeAddForm': case 'deliveryTypeEditForm': if (!isset($prefix_len)) { $prefix_len = strlen('deliveryType'); } $action = substr($name, $prefix_len); $action = substr($action, 0, strlen($action) - 4); $form = new AppForm($this, $name); if (substr($name, strlen($name) - 8) === 'EditForm') { $form->addHidden('id'); } $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.')); $form->addText('price', __('Price:'))->addRule(Form::FILLED, __('You have to entry price.'))->addRule(Form::NUMERIC, __('Price has to be a number.')); $form->addSubmit('ok', '✔ ' . __($action)); $form->onSubmit[] = array($this, 'on' . substr($name, 0, strlen($name) - 4) . 'Submit'); break; case 'changeOrderStatusForm': $form = new AppForm($this, $name); $statuses = array(0 => __('–––')); foreach (mapper::order_statuses()->findAll() as $_) { $statuses[$_->getId()] = $_->getName(); } $form->addSelect('status_id', __('Status:'), $statuses)->skipFirst()->addRule(Form::FILLED, __('You have to entry status.')); $form->addHidden('id'); $form->addSubmit('ok', '✔ ' . __('Change')); $form->onSubmit[] = array($this, 'onChangeOrderStatusFormSubmit'); break; case 'sendMailForm': $form = new AppForm($this, $name); $form->addText('to', __('To:'))->addRule(Form::EMAIL, __('E-mail has to be an e-mail.')); $form->addText('subject', __('Subject:'))->addRule(Form::FILLED, __('You have to entry subject.')); $form->addTextArea('body', __('Body:'))->addRule(Form::FILLED, __('You have to entry text.')); $form->addSubmit('ok', '✔ ' . __('Send')); $form->onSubmit[] = array($this, 'onSendMailFormSubmit'); $form->addHidden('order_id'); break; default: parent::createComponent($name); } }
private function formNewEditFields(AppForm $form) { $form->addGroup('Content')->setOption('container', Html::el('fieldset')->id('contents')); $form->addText('title', 'Title')->addRule(Form::FILLED, 'Fill title'); $form->addTextarea('content', 'Text'); $templates = $this->model('contentTemplates')->get('page'); $form->addGroup('Properties')->setOption('container', Html::el('fieldset')->id('properties')); $categories = $this->model('categories')->getPairs(); $categories = array('0' => 'none') + $categories; $form->addSelect('category', 'Category', $categories); $form->addCheckBox('homepage', 'Set as homepage?'); $form->addSelect('template', 'Template', $templates); $form->addCheckBox('has_widgets', 'Has widgets'); $form->addText('publish_time', 'Publish time'); //$form->addText('time', ''); $form->addText('keywords', 'keywords'); $form->addTextarea('description', 'description'); $form->addHidden('content_type')->setValue('page'); if ($form->name == 'formNewPage') { //$form->addGroup('Link')->setOption('container', Html::el('fieldset')->id('link')); $menus = $this->model('menu')->getPairs(); $menus = array(0 => 'none') + $menus; $form->addSelect('link', 'Link in menu', $menus); } $form->addTextArea('css_files', 'Css files')->getControlPrototype()->{'data-ext'} = 'css'; $form->addTextArea('js_files', 'Js files')->getControlPrototype()->{'data-ext'} = 'js'; $form->addGroup('')->setOption('container', Html::el('fieldset')->id('buttons')); $form->addButton('btnClose', 'Close'); $form->addSubmit('btnPreview', 'Preview')->onClick[] = array($this, 'formNewPagePreview'); $form['btnPreview']->getControlPrototype()->class('ajax'); return $form; }
public function createComponentPageEditForm() { $form = new AppForm(); $form->getElementPrototype()->class('ajax'); $form->addHidden("id_page"); $form->addText("heading", "nadpis"); $form->addText("name", "v menu"); $form->addText("seoname", "adresa")->setAttribute('placeholder', '(automatická)'); $form->addCheckbox("published", "publikováno"); $form->addTextArea("text", "obsah stránky"); $form['text']->getControlPrototype()->class('textarea'); $form->addSubmit("submit1", "Uložit"); $form->onSuccess[] = callback($this, 'pageEditFormSubmitted'); //add additional inputs $this->triggerEvent_filter('filterPageEditForm_create', $form); return $form; }
protected function createComponentForm($name) { $form = new AppForm(); //$form->getElementPrototype()->id('editform'); $form->addText('title', 'Název', 50)->addRule(Form::FILLED, "Jméno je potřeba vyplnit"); $items = dibi::query('SELECT authorId, CONCAT_WS(" ", name, surname,', Model::sqlClassName(Model::getSchoolYear()), ') as authorName FROM [authors] ORDER BY surname, class desc')->fetchPairs(); $keys = array_keys($items); $form->addSelect('author', 'Autor', array("0" => 'Nový') + $items)->setValue($keys[0]); $form->addTextArea('text', 'Text')->getControlPrototype()->style = 'width: 100%'; $form->addSelect('award', 'Ocenění', array("0" => 'Nové') + $this->setKeys(Model::getValues('award', 'works'))); $form->addText('newAward', ''); $form->addSelect('year', 'Ročník ChP', $this->generateYears())->setDefaultValue(Model::getSchoolYear()); $form->addSelect('type', 'Typ', array("0" => 'Nový') + $this->setKeys(Model::getValues('type', 'works'))); $form->addText('newType', ''); if ($this->setId == '') { $form->addFile('file', "Soubor:"); } $form['newAward']->addConditionOn($form['award'], Form::EQUAL, 0)->addRule(Form::FILLED, 'Pokud nevyberete ocenění, musíte zadat nové'); $form['newType']->addConditionOn($form['type'], Form::EQUAL, 0)->addRule(Form::FILLED, 'Pokud nevyberete typ, musíte zadat nový'); $form->addSubmit('ok', 'Přidat práci')->onClick[] = array($this, 'addClicked'); $form->addHidden("authorId")->setValue('false'); if ($this->setId != '') { $dataSource = dibi::query('SELECT * FROM [works] WHERE workId=%i', $this->setId)->fetch(); $form->setDefaults($dataSource); $form['ok']->onClick = array(array($this, 'saveClicked')); $form['ok']->caption = "Uložit práci"; $form->addHidden("workId")->setValue($this->setId); } else { $s = Environment::getSession('workform'); if (isset($s->author) && array_search($s->author, $keys) === FALSE) { $s->author = $keys[0]; } if (isset($s->author)) { $form->setDefaults($s); } } $this->addComponent($form, $name); $form->getRenderer()->wrappers['control']['container'] .= ' class="wide"'; return; }