本文整理汇总了PHP中Nette\Application\UI\Form::addCheckboxList方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addCheckboxList方法的具体用法?PHP Form::addCheckboxList怎么用?PHP Form::addCheckboxList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::addCheckboxList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentVlozMineralForm
protected function createComponentVlozMineralForm()
{
$skupina = $this->skupinaRepository->findAllSkupina()->fetchPairs('id', 'nazov');
$krystalografickaSustava = $this->ciselnikkrystalografickasustavaRepository->findAllKrystalografickaSustava()->fetchPairs('id', 'vlastnost');
$vryp = $this->ciselnikvrypRepository = $this->ciselnikvrypRepository->findAllVryp()->fetchPairs('id', 'vlastnost');
$stiepatelnost = $this->ciselnikstiepatelnostRepository = $this->ciselnikstiepatelnostRepository->findAllStiepatelnost()->fetchPairs('id', 'vlastnost');
$farba = $this->ciselnikfarbaRepository->findAllFarba()->fetchPairs('id', 'vlastnost');
$lesk = $this->ciselnikleskRepository->findAllLesk()->fetchPairs('id', 'vlastnost');
$lom = $this->ciselniklomRepository->findAllLom()->fetchPairs('id', 'vlastnost');
$form = new Form();
$form->addText('nazov', 'Názov minerálu', 40, 100)->addRule(Form::FILLED, 'Je nutné zadať názov');
$form->addSelect('skupina', 'Skupina', $skupina)->setPrompt('- Zvoľte skupinu -');
$form->addText('chemickeZlozenie', 'Chemické zloženie', 40, 100);
$form->addSelect('krystalografickaSustava', 'Kryštalografická sústava', $krystalografickaSustava)->setPrompt('- Zvoľte sústavu -');
$form->addSelect('vryp', 'Vryp', $vryp)->setPrompt('- Zvoľte vryp -');
$form->addText('tvrdostOd', 'tvrdosť od', 40, 100);
$form->addText('tvrdostDo', 'tvrdosť do', 40, 100);
$form->addSelect('stiepatelnost', 'Štiepateľnosť', $stiepatelnost)->setPrompt('- Zvoľte štiepateľnosť -');
$form->addText('hustotaOd', 'hustota od', 40, 100);
$form->addText('hustotaDo', 'hustota do', 40, 100);
$form->addCheckboxList('farba', 'farba', $farba);
$form->addCheckboxList('lesk', 'lesk', $lesk);
$form->addCheckboxList('lom', 'lom', $lom);
$form->addSubmit('create', 'Vložiť minerál');
$form->onSuccess[] = $this->vlozMineralFormSubmitted;
return $form;
}
示例2: createComponentSurveyForm
public function createComponentSurveyForm()
{
$form = new Nette\Application\UI\Form();
$form->addRadioList('mark', 'Aplikaci', [1 => 'navštěvuji denně', 2 => 'používám každý týden', 3 => 'jen když jsem někde byl', 4 => 'vidím poprvé a znova ji nepoužiji'])->setAttribute('class', 'zelená');
$form->addCheckboxList('mostly', 'Nejčastěji', [1 => 'chodím na tůry do lesa', 2 => 'trávím čas u vody', 3 => 'cestuji do zahraničí', 4 => 'sedím doma'])->setAttribute('class', 'zelená');
$form->addCheckboxList('future', 'Chci', [1 => 'sdílení výletů', 2 => 'filtrovat výlety v mapě', 3 => 'modul na geoCaching'])->setAttribute('class', 'zelená');
$form->addSubmit('send', 'Odeslat');
Helpers::bootstrapForm($form);
return $form;
}
示例3: createComponentQuickSearchForm
/**
* Quick Search form factory.
*
* @return \Nette\Application\UI\Form
*/
protected function createComponentQuickSearchForm()
{
$form = new Form();
$form->setMethod('GET');
$form->addText('q', 'Query:');
$form->addCheckboxList('filter', 'filter', ['light' => 'LIGHT', 'large' => 'LARGE']);
$form->addSubmit('search', 'Search');
$filter = [];
if ($this->filterLight) {
$filter[] = 'light';
}
if ($this->filterLarge) {
$filter[] = 'large';
}
$form->setDefaults(['q' => $this->fulltextQuery, 'filter' => $filter]);
$form->onSuccess[] = $this->quickSearchFormSucceeded;
return $form;
}
示例4: create
public function create()
{
$form = new Form();
$form->addText("title")->addRule(Form::MAX_LENGTH, "Maximální délka nadpisu může být %d znaků.", Article::MAX_TITLE_LENGTH)->setRequired("Zadej prosím nadpis článku.");
$form->addTextArea("content")->setAttribute("rows", 15)->setAttribute("cols", 7)->setRequired("Zadej prosím text článku.");
$form->addCheckboxList("categories", null, $this->categories)->setRequired("Vyber prosím alespoň jednu kategorii.");
$form->addText("tags")->setAttribute("size", 30);
$form->addButton("addTag");
$form->addRadioList("publishedAt", null, array("now" => "Publikovat ihned", "noChange" => "Ponechat stávající", "later" => "Naplánovat na"))->setRequired("Zadej prosím datum vydání.");
$form->addText("day")->setAttribute("size", 2)->setRequired("Zadej prosím den vydání.")->addRule(Form::RANGE, "Den musí být číselná hodnota v intervalu %d až %d.", array(1, 31))->setDefaultValue(date("j"));
$form->addSelect("month")->setItems(DateTimeUtils::getMonths(), true)->setDefaultValue(date("n"));
$form->addSelect("year")->setItems(DateTimeUtils::getYears(), false)->setDefaultValue(date("Y"));
$form->addText("hour")->setAttribute("size", 2)->setRequired("Zadej prosím hodinu vydání.")->addRule(Form::RANGE, "Hodina musí být číselná hodnota v intervalu %d až %d.", array(0, 23))->setDefaultValue(date("H"));
$form->addText("minute")->setAttribute("size", 2)->setRequired("Zadej prosím minutu vydání.")->addRule(Form::RANGE, "Minuta musí být číselná hodnota v intervalu %d až %d.", array(0, 59))->setDefaultValue(date("i"));
$form->addSubmit("submit");
$form->onValidate[] = array($this, "validateAddArticleForm");
$form->onSuccess[] = array($this, "addArticleFormSucceeded");
return $form;
}
示例5: createComponentContactForm
public function createComponentContactForm()
{
$form = new Form();
$form->addText('name', 'Your name:')->setRequired();
$form->addText('email', 'Your e-mail:')->setType('email')->addRule(Form::EMAIL, 'That doesn\'t look like a proper e-mail address. Please check your e-mail address for typos and send the form again.');
$form->addText('phone', 'Your phone number:')->setType('tel')->addRule(Form::PATTERN, 'Please specify your phone number in the international format', '(00|\\+)[\\d\\s]+');
$form->addRadioList('preferred', 'Preferred contact:', ['phone' => 'Phone', 'email' => 'E-mail'])->setRequired();
$subjects = ['general' => 'General Questions', 'complaint' => 'Quality of Service Complaints', 'idea' => 'Ideas for Improvement'];
$form->addSelect('topic', 'Message topic:', $subjects)->setRequired();
$form->addTextArea('content', 'Your message:', 40, 4)->setRequired();
$form->addUpload('attachments', 'Attachments (only JPEG images allowed):', true)->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Only JPEG images are allowed', 'image/jpeg');
$newsletters = ['weekly' => 'Weekly reports', 'promo' => 'Promotional bulletins', 'ads' => 'Interesting offers'];
$form->addCheckboxList('subscribe', 'Subscribe to:', $newsletters);
$form->addCheckbox('terms', 'I agree to the terms and conditions')->setOmitted()->setRequired();
$form->addSubmit('send', 'Send message')->onClick[] = [$this, 'informMessageSent'];
$form->addSubmit('save', 'Save message')->onClick[] = [$this, 'informMessageSaved'];
$form->onSuccess[] = [$this, 'doSendMessage'];
return $form;
}
示例6: create
/**
* @param Category[] $categories
* @param string|null $code
* @return Form
*/
public function create($categories, $code = null)
{
$validaton_message = "Vyplňte prosím %s. Pomůže mi to lépe zpracovat výsledky průzkumu. Díky ;)";
$form = new Form($this->parent, $this->name);
$form->addGroup("Obecné");
$sex = array(Respondent::GENDER_MALE => 'muž', Respondent::GENDER_FEMALE => 'žena');
$form->addRadioList('gender', 'Pohlaví:', $sex)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "svoje pohlaví");
$age = array(Respondent::AGE_15 => 'méne něž 15', Respondent::AGE_15_20 => '15-20', Respondent::AGE_21_30 => '21-30', Respondent::AGE_31_45 => '31-45', Respondent::AGE_46_60 => '46-60', Respondent::AGE_60 => 'více než 60');
$form->addRadioList('age', 'Věk', $age)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "svůk věk");
$truefalseoptions = array(1 => "Ano", 0 => "Ne");
$form->addRadioList("english", "Navštěvuji anglické webové stránky", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda navštěvujete i anglické webové stránky");
$form->addRadioList("it", "Pracuji v oboru IT nebo tento obor studuji", $truefalseoptions)->setAttribute('class', 'buttons-group')->addRule(Form::REQUIRED, $validaton_message, "zda pracujete v oboru IT nebo ho studujete");
if ($code !== null) {
$form->addHidden("code", $code);
}
$form->addTextArea("sites", "Jaké stránky často navštěvuji");
$devices = array(Respondent::DEVICE_COMPUTER => "Počítač nebo notebook", Respondent::DEVICE_PHONE => "Smartphone", Respondent::DEVICE_TABLET => "Tablet");
$form->addCheckboxList('device', 'K přístupu na internet používám:', $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení používáte pro přístup k internetu");
$form->addRadioList("device_most", "A z toho nejčastěji", $devices)->setAttribute("class", "buttons-group")->addRule(Form::REQUIRED, $validaton_message, "které zařízení nejčastěji používáte pro přístup k internetu");
$period = array(EntityCategory::PERIOD_NEVER => "vůbec", EntityCategory::PERIOD_DAILY => "denně", EntityCategory::PERIOD_FEW_TIMES_A_WEEK => "několikrát týdně", EntityCategory::PERIOD_FEW_TIMES_A_MONTH => "několikrát měsíčně", EntityCategory::PERIOD_FEW_TIMES_A_YEAR => "několikrát ročně");
$categories_container = $form->addContainer("category");
foreach ($categories as $holder_category) {
$category_container = $categories_container->addContainer($holder_category->getCategory()->id_category);
$category_container->setCurrentGroup($categories_container->getForm()->addGroup($holder_category->getCategory()->label));
$category_container->addRadioList("period", "Jak často?", $period)->setAttribute("class", "buttons-group");
if ($holder_category->getChildren()) {
$items = array();
foreach ($holder_category->getChildren() as $child) {
$items[$child->id_category] = $child->label;
}
$category_container->addCheckboxList("items", $holder_category->getCategory()->child_label, $items)->setAttribute("class", "buttons-group");
}
}
$form->setCurrentGroup(NULL);
$form->addGroup("Zajímá mě to");
$form->addText("nickname", "Nick (chci být v highscore)");
$form->addText("email", "E-mail")->setType("email");
$form->addTextArea("message", "Vzkaz");
$form->addSubmit("validate", "Pokračovat")->setAttribute("class", "btn btn-primary");
$form->addSubmit("nonvalidate", "Přejít rovnou k otázkám")->setValidationScope(FALSE)->setAttribute("class", "btn btn-default");
return $form;
}
示例7: createComponentDemoForm
public function createComponentDemoForm()
{
$form = new Form();
if (class_exists('Instante\\Bootstrap3Renderer\\BootstrapRenderer')) {
$form->setRenderer(new BootstrapRenderer());
}
$form->addGroup('Text fields');
$form->addText('email', 'Email')->setType('email')->setOption('placeholder', 'Email');
$form->addTextArea('textarea', 'Textarea');
$form->addPassword('password', 'Heslo')->setOption('placeholder', 'Heslo');
$form->addGroup('Other fields');
$form->addSelect('select', 'Select', ['foo' => 'Foo', 'bar' => 'Bar'])->setPrompt('-choose-')->addError('This field is in an error state');
$form->addCheckboxList('checkboxlist', 'Checkbox List', ['foo' => 'Foo', 'bar' => 'Bar']);
$form->addRadioList('rlist', 'Radio List', ['foo' => 'Foo', 'bar' => 'Bar']);
$form->addCheckbox('remember', 'Neodhlašovat');
$form->addSubmit('send', 'Přihlásit')->setOption('btn-class', 'btn-primary');
$form->addSubmit('s2', 'Submit 2');
$form->addError('This is global form error');
return $form;
}
示例8: createComponentExampleOneForm
public function createComponentExampleOneForm()
{
$form = new Form();
$form->addText('name', "Name:");
$form->addPassword('password', "Password:");
$form->addTextArea('textarea', "Textarea");
$form->addSelect('select', "Select", ['Option 1', 'Option 2']);
$form->addUpload('upload', 'Upload');
$form->addCheckbox('checkbox', 'Checkbox');
$form->addRadioList('radioList', 'Radio list', ['Item A', 'Item B']);
$form->addCheckboxList('checkboxList', 'Checkbox list,', ['Item A', 'Item B']);
$form->addText('date', 'Date:')->getControlPrototype()->class('b-date-input');
$form->addText('datetime', 'Date time:')->getControlPrototype()->class('b-date-input b-date-input--datetime');
$now = new DateTime();
$now->modify('+1 day');
$now->modify('+3 hour');
$form->setDefaults(['date' => $now, 'datetime' => $now]);
$form->addSubmit('actionSend', 'Save');
$form->onSuccess[] = array($this, 'exampleOneFormSubmitted');
return $form;
}
示例9: createComponentPolozkaForm
protected function createComponentPolozkaForm($name)
{
$skupina = $this->ciselnikSkupinaRepository->findAll()->fetchPairs('id', 'nazov');
$farba = $this->ciselnikFarbaRepository->findAll()->fetchPairs('id', 'nazov');
$podskupina = $this->ciselnikPodskupinaRepository->findAll()->fetchPairs('id', 'nazov');
$textura = $this->ciselnikTexturaRepository->findAll()->fetchPairs('id', 'nazov');
$struktura = $this->ciselnikStrukturaRepository->findAll()->fetchPairs('id', 'nazov');
$lokalitaSlovensko = $this->lokalitaSlovenskoRepository->findAll()->fetchPairs('id', 'nazov');
$form = new Form();
$form->addText('nazov', 'Nazov')->setRequired('Zvolte nazov');
$form->addSelect('idCiselnikSkupina', 'Skupina', $skupina);
$form->addSelect('idCiselnikFarba', 'Farba', $farba);
$form->addSelect('idCiselnikPodskupina', 'Podskupina', $podskupina);
$form->addCheckboxList('textura', 'textura', $textura);
$form->addCheckboxList('struktura', 'struktura', $struktura);
$form->addCheckboxList('lokalitaSlovensko', 'Lokalita Slovensko', $lokalitaSlovensko);
$form->addSubmit('uloz', 'Uloz')->onClick[] = callback($this, 'nazovFormSubmitted');
$form->addSubmit('cancel', 'Storno')->onClick[] = callback($this, 'cancelFormSubmitted');
return $form;
}
示例10: createComponentFilters
public function createComponentFilters()
{
// getSession values
//->setDefaultValue($year)
$session = $this->getSession('filters');
// returns the whole Session
//dump($session->year);
if (!isset($session->year)) {
$session->genres = null;
$session->year = null;
$session->sort = null;
}
$years = array();
$filters = $this->getSession();
for ($i = intval(date("Y")); $i > 1960; $i--) {
$years[$i] = $i;
}
$form = new UI\Form();
$form->addCheckboxList('genres', 'Genres:', array('35' => 'Comedy', '18' => 'Drama', '10749' => 'Romance', '28' => 'Action', '10751' => 'Family', '10402' => 'Music', '99' => 'Documentary', '80' => 'Crime', '53' => 'Thriller', '10752' => 'War', '27' => 'Horror', '37' => 'Western', '12' => 'Adventure', '14' => 'Fantasy', '878' => 'Sci-Fi'))->setDefaultValue($this->getSession('filters')->genres);
$form->addSelect('year', 'Year:', $years)->setPrompt('None')->setDefaultValue($this->getSession('filters')->year);
$form->addSelect('sort', 'Sort by:', array('original_title.asc' => 'Name ▲', 'original_title.desc' => 'Name ▼', 'vote_average.asc' => 'Rating ▲', 'vote_average.desc' => 'Rating ▼', 'primary_release_date.asc' => 'Release date ▲', 'primary_release_date.desc' => 'Release date ▼'))->setDefaultValue($this->getSession('filters')->sort);
$form->addSubmit('submit', 'Filter');
$form->onSuccess[] = array($this, 'filterFormSucceeded');
return $form;
}
示例11: createComponentFilterForm
protected function createComponentFilterForm()
{
$websites_arr = array();
foreach ($this->website_service->getAll() as $website) {
$websites_arr[$website->id_website] = $website->name;
}
$pages_arr = array();
foreach ($this->page_service->getBasePageHolders() as $pageHolder) {
$pages_arr[$pageHolder->getPage()->id_page] = $pageHolder->getWebsite()->name . " - " . $pageHolder->getPage()->name;
}
$form = new \Nette\Application\UI\Form();
$form->addGroup('Filtrování');
$form->addText('id', 'Id');
$form->addText('id_question', 'Rodič');
$input_respondent = $form->addText('id_respondent', 'Respondent');
if ($this->id_respondent !== null) {
$input_respondent->setDefaultValue($this->id_respondent);
}
$form->addText('wireframe', 'Wireframe');
$form->addText('datetime', 'Čas');
$form->addCheckboxList('state', 'Stav', array(\App\Model\Subquestion::STATE_CORRECT => "OK", \App\Model\Subquestion::STATE_ALMOST => "téměř", \App\Model\Subquestion::STATE_WRONG => "NE", \App\Model\Subquestion::STATE_DISQUALIFIED => "nepočítat"));
$form->addText('answer', 'Odpověď');
$form->addText('reason', 'Důvod');
$form->addText('type', 'Typ');
$form->addText('seconds', 'Sekundy');
$form->addCheckboxList('know', 'Zná?', array("null" => "nevyplněno", RespondentWebsite::PERIOD_DONT_KNOW => 'neznám', RespondentWebsite::PERIOD_KNOW_THAT_EXISTS => 'vím, že existuje', RespondentWebsite::PERIOD_KNOW_AND_VISIT => 'znám a navštěvuji'));
$websites = $form->addDynamic("id_website", function (Container $website) use($websites_arr) {
$website->addSelect("id_website", "Web", $websites_arr);
$website->addSubmit('removeWebsite', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem');
});
$websites->addSubmit('addWebsite', 'Přidat web')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem');
$pages = $form->addDynamic("id_page", function (Container $website) use($pages_arr) {
$website->addSelect("id_page", "Stránka", $pages_arr);
$website->addSubmit('removePage', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem');
});
$pages->addSubmit('addPage', 'Přidat stránku')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem');
$this->addOrder($form, array('subquestion.id_subquestion' => "id", 'question.id_question' => "rodič", 'subquestion.seconds' => 'sekundy', 'question.id_respondent' => 'respondent', 'subquestion.datetime' => 'čas'));
$form->onSuccess[] = $this->filterFormSubmited;
$form->addGroup();
$form->addSubmit('filter', 'Filtrovat')->setAttribute("class", "btn btn-primary ajax");
return $form;
}
示例12: createComponentItemForm
protected function createComponentItemForm()
{
$form = new UI\Form();
$form->addText('name', 'Název výrobku:')->setRequired();
$categories = $this->category->order('name')->fetchPairs('id', 'name');
$manufacturers = $this->manufacturer->order('name')->fetchPairs('id', 'name');
$manufacturers[null] = '--- Žádný výrobce ---';
$form->addCheckboxList('category_id', 'Kategorie', $categories);
$form['category_id']->setAttribute('class', 'small');
$form->addSelect('manufacturer_id', 'Výrobce', $manufacturers)->setDefaultValue('');
$form->addCheckbox('showPrice', 'Zobrazovat cenu?')->addCondition($form::EQUAL, TRUE)->toggle('price');
$form->addText('price', 'Cena za ks včetně DPH')->setType('number')->setDefaultValue(0)->setOption('id', 'price')->addRule($form::RANGE, 'Cena nemůže být záporná.', array(0, 1000000000));
$form->addCheckbox('recommended', 'Je zboží doporučené?');
$form->addCheckbox('new', 'Je to novinka?');
$form->addCheckbox('clearance_sale', 'Doprodej?');
$form->addCheckbox('stock', 'Skladem?');
$form->addCheckbox('order', 'Na objednávku?');
$form->addUpload('photo', 'Přidat obrázek výrobku:');
$form->addTextArea('description', 'Popis:')->setAttribute('class', 'tinyMCE');
$form->addSubmit('save', 'Uložit')->setAttribute('class', 'btn btn-primary');
$form->onSuccess[] = array($this, 'itemFormSucceeded');
return $form;
}
示例13: createComponentSongEditor
protected function createComponentSongEditor()
{
$form = new Form();
$form->addText('name', 'Song')->setRequired('Zadejte název songu');
$form->addText('interpret_name', 'Interpret')->setRequired('Zadejte jméno interpreta');
$form->addSelect('interpret_id', 'Asociovat s', $this->interpreti->findAll()->fetchPairs('id', 'nazev'))->setPrompt('Vyberte asociaci');
$form->addSelect('zanr_id', 'Žánr', $this->zanry->findAll()->fetchPairs('id', 'name'))->setPrompt('Vyberte žánr')->setRequired('Vyberte žánr songu');
$form->addSelect('status', 'Status', ['waiting' => 'Čeká na schválení', 'approved' => 'Schválen', 'rejected' => 'Zamítnut'])->setRequired('Zadejte stav songu');
$form->addSelect('reason_code', 'Kód zamítnutí', \Rejections::$reasons)->setPrompt('Vyberte kód zamítnutí')->addConditionOn($form['status'], Form::EQUAL, 'rejected')->addRule(Form::FILLED, 'Musíte udat kód zamítnutí');
$form->addText('zadatel', 'Přezdívka žadatele')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Přezdívka žadatele musí mít minimálně %s znaků', 3);
$form->addSelect('user_id', 'Účet žadatele', $this->users->getUsers()->fetchPairs('id', 'username'))->setPrompt('Vyberte uživatele');
$form->addCheckboxList('flags', 'Flagy', ['pecka' => 'Pecka', 'instro' => 'Má instro', 'remix' => 'Remix', 'wishlist_only' => 'Pouze na přání']);
$form->addText('link', 'URL k poslechu')->addCondition(Form::FILLED)->addRule(Form::URL, 'URL není v platném formátu');
$form->addTextArea('note', 'Poznámka DJe');
$form->addTextArea('vzkaz', 'Vzkaz pro DJe');
$form->addCheckbox('private_vzkaz', 'Vzkaz je soukromý');
$form->addHidden('id');
$form->addSubmit('send', 'Přidat');
$form->onSuccess[] = function (Form $f) {
$val = $f->getValues(true);
foreach ($val['flags'] as $flag) {
$val[$flag] = true;
}
unset($val['flags']);
//clear bordel
//If requester not filled => assign to you
if (!$val['zadatel'] && !$val['user_id']) {
$val['zadatel'] = $this->user->identity->username;
$val['user_id'] = $this->user->id;
}
//If requester not filled BUT USER ID engaged => fetch username for requester name
if (!$val['zadatel'] && $val['user_id']) {
$val['zadatel'] = $this->users->getUser($val['user_id'])->username;
}
try {
if ($val['id']) {
$original = $this->songy->find($val['id']);
if ($original->status != $val['status']) {
$val['revisor'] = $this->user->id;
}
$original->update($val);
$this->logger->log('Song', 'edit', "%user% upravila(a) song {$original->name}");
$msg = $this->flashMessage("Song '{$val['interpret_name']} - {$val['name']}' upraven.", 'success');
$msg->title = 'A je tam!';
$msg->icon = 'check';
} else {
$val['image'] = json_encode($this->lfm->getTrackImage($val['interpret_name'], $val['name'])) ?: '';
$val['revisor'] = $this->user->id;
$song = $this->songy->add($val);
$this->logger->log('Song', 'create', "%user% vytvořila(a) song {$song->name}");
$msg = $this->flashMessage("Song '{$val['interpret_name']} - {$val['name']}' přidán.", 'success');
$msg->title = 'A je tam!';
$msg->icon = 'check';
}
} catch (\UnexpectedValueException $e) {
$msg = $this->flashMessage($e->getMessage(), 'danger');
$msg->title = 'Oh shit!';
$msg->icon = 'exclamation';
}
$this->redirect('this');
};
return $form;
}
示例14: createComponentFilterForm
protected function createComponentFilterForm()
{
$form = new \Nette\Application\UI\Form();
$form->addGroup('Filtrování');
$form->addText('id', 'Id');
$form->addText('datetime', 'Čas');
$form->addCheckboxList('age', 'Věk', array("null" => "neznámé", \App\Model\Respondent::AGE_15 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_15), \App\Model\Respondent::AGE_15_20 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_15_20), \App\Model\Respondent::AGE_21_30 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_21_30), \App\Model\Respondent::AGE_31_45 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_31_45), \App\Model\Respondent::AGE_46_60 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_46_60), \App\Model\Respondent::AGE_60 => \App\Utils\Respondent::getAgeLabel(\App\Model\Respondent::AGE_60)));
$form->addCheckboxList('gender', 'Pohlaví', array("null" => "neznámé", \App\Model\Respondent::GENDER_MALE => "muž", \App\Model\Respondent::GENDER_FEMALE => "žena"));
$form->addCheckboxList('english', 'Angličtina', array("null" => "neznámé", 1 => "ano", 0 => "ne"));
$form->addCheckboxList('it', 'It', array("null" => "neznámé", 1 => "ano", 0 => "ne"));
$form->addCheckboxList('devices', 'Zařízení', array(\App\Model\Respondent::DEVICE_COMPUTER => "počítač", \App\Model\Respondent::DEVICE_PHONE => "smartphone", \App\Model\Respondent::DEVICE_TABLET => "tablet"));
$form->addCheckboxList('device_most', 'Nejčastější zařízení', array("null" => "neznámé", \App\Model\Respondent::DEVICE_COMPUTER => "počítač", \App\Model\Respondent::DEVICE_PHONE => "smartphone", \App\Model\Respondent::DEVICE_TABLET => "tablet"));
$form->addText('websites', 'Navštěvované stránky');
$form->addText('questions', 'Otázek');
$form->addText('subquestions', 'Podotázek');
$form->addText('correct', 'Správně');
$form->addText('wrong', 'Špatně');
$form->addText('almost', 'Téměř');
$form->addText('disqualified', 'Nepočítané');
$form->addText('unknown', 'Nevyhodnoceno');
$form->addText('percentages', 'Procenta');
$this->addOrder($form, array('respondent.id_respondent' => 'id', 'respondent.datetime' => 'čas', 'total_questions' => 'počet otázek', 'total_subquestions' => 'počet podotázek', 'total_correct_subquestions' => 'správně', 'total_wrong_subquestions' => 'špatně', 'total_almost_subquestions' => 'téměř', 'total_disqualified_subquestions' => 'nepočítané', 'total_unknown_subquestions' => 'nevyhodnoceno', 'total_correct_subquestions_percents' => 'úspěšnost'));
$form->onSuccess[] = $this->filterFormSubmited;
$form->addGroup();
$form->addSubmit('filter', 'Filtrovat')->setAttribute("class", "btn btn-primary ajax");
return $form;
}
示例15: createComponentAddImageForm
} else {
$this->redirect('Clanky:default', $this->id_hlavne_menu);
}
}
}
/** Formular pre pridanie obrazku k produktu.
* @return Nette\Application\UI\Form
*/
public function createComponentAddImageForm()
{
$form = new Form();
$form->addProtection();