本文整理汇总了PHP中Nette\Application\UI\Form::addDynamic方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addDynamic方法的具体用法?PHP Form::addDynamic怎么用?PHP Form::addDynamic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::addDynamic方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentForm
protected function createComponentForm()
{
$form = new Nette\Application\UI\Form();
$addEventHandler = callback($this, 'handleAddItem');
$removeEventHandler = callback($this, 'handleRemoveItem');
$form->addGroup('Footer menu');
$form->addDynamic('sections', function (Container $column) use($removeEventHandler, $addEventHandler) {
$column->addText('title', 'Column Title')->getControlPrototype()->addClass('col-sm-5')->addAttributes(['placeholder' => 'Column Title']);
$column->addDynamic('menuItems', function (Container $menuItems) use($removeEventHandler) {
$menuItems->addText('text', 'Text')->getControlPrototype()->addClass('col-sm-5')->addAttributes(['placeholder' => 'Text']);
$menuItems->addText('url', 'Url')->getControlPrototype()->addClass('col-sm-5')->addAttributes(['placeholder' => 'Url']);
$menuItems->addSubmit('remove', '-')->setValidationScope(false)->setAttribute('class', 'btn-danger btn-sm')->setAttribute('data-replicator-item-remove', 'yes')->addRemoveOnClick($removeEventHandler);
$this->controlsInit($menuItems);
}, 1, true)->addSubmit('add', '+')->setValidationScope(false)->setAttribute('class', 'btn btn-success btn-sm')->addCreateOnClick(true, $addEventHandler);
$column->addSubmit('remove', '-')->setValidationScope(false)->setAttribute('class', 'btn-sm btn-danger')->setAttribute('data-replicator-item-remove', 'yes')->addRemoveOnClick($removeEventHandler);
$this->controlsInit($column);
}, 2, true)->addSubmit('add', '+')->setValidationScope(false)->setAttribute('class', 'btn btn-sm btn-success')->addCreateOnClick(true, $addEventHandler);
$form->addGroup();
$form->addSubmit('submit', 'Save');
$form->addSubmit('cancel', 'Cancel');
$this->controlsInit($form);
$form->getElementPrototype()->addClass('form-horizontal');
$form->onSuccess[] = $this->processForm;
$form->setRenderer(new Bs3FormRenderer());
return $form;
}
示例2: addOrder
/**
* @param \Nette\Application\UI\Form $form
* @param string[] Items
*/
protected function addOrder($form, $items)
{
$form->addGroup('Řazení');
$order = $form->addDynamic('order', function (Container $order) use($items) {
$order->addSelect('by', 'Položka', $items);
$order->addRadioList('dir', 'Směr', array('asc' => 'vzestupně', 'desc' => 'sestupně'));
$order->addSubmit('removeOrder', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem');
});
$order->addSubmit('addOrder', 'Přidat řazení')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem');
}
示例3: createComponentLabelVideosForm
/**
* Form for labeling videos of an event
* Can only be creating in videos action and accessed by
* somebody with videos or higher privileges
*
* @Privilege('videos')
* @Action('videos')
*/
protected function createComponentLabelVideosForm()
{
$form = new Form();
$form->addProtection('Vypršel časový limit, odešlete formulář znovu');
$form->addHidden('id');
$form->addDynamic('chronicle_videos', function (Container $container) {
$container->addHidden('id');
$container->addTextarea('note', 'Nadpis/popisek videa:');
$container->addTextarea('input', 'HTML Kód pro zobrazení videa:');
$container->addSubmit('remove', 'Odebrat video')->setValidationScope(FALSE)->addRemoveOnClick();
//intentional, delete after whole form submit
}, 1)->addSubmit('add', 'Přídat další video')->setValidationScope(FALSE)->addCreateOnClick(TRUE);
if ($this->user->isAllowed('Admin:Default:Chronicle', 'show')) {
$form->addCheckbox('showchronicle', 'Zobrazit kroniku:')->setDefaultValue(TRUE);
}
$form->addSubmit('send', 'Odeslat')->onClick[] = $this->labelVideosFormSucceded;
return $form;
}
示例4: 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;
}
示例5: createComponentNewTestForm
/**
* NewTest form form factory.
* @return Nette\Application\UI\Form
*/
protected function createComponentNewTestForm()
{
$form = new Nette\Application\UI\Form();
$presenter = $this;
$invalidateCallback = function () use($presenter) {
/** @var \Nette\Application\UI\Presenter $presenter */
$presenter->invalidateControl('newTestForm');
$presenter->invalidateControl('newTestScripts');
$stop();
};
$form->addText('name', 'Název testu: ')->setRequired('Zadejte prosím název testu.');
$attempts = ['Neomezeně', '1', '2', '3', '4', '5', '10', '20'];
$form->addSelect('attempts', 'Počet pokusů: ', $attempts);
$form->addText('test_password', 'Heslo: (nepovinné)');
//Questions
$questions = $form->addDynamic('questions', function (Container $question) use($invalidateCallback) {
$question->addText('question', $question->name + 1 . '. Otázka: ');
$question->addUpload('question_img', 'Obrázek k otázce:');
$question->addHidden('question_img_filename');
//Answer type
$types = array('radio' => 'Jedna správná <span class="smhide">odpovědi</span>', 'checkbox' => 'Více správných <span class="smhide">odpovědí</span>', 'text' => 'Textová <span class="xshide">odpověď</span>');
$question->addRadioList('type', 'Typ odpovědi: ', $types);
// ->setDefaultValue('radio');
//Single answer
$question->addText('answer_a', 'Odpověď A:');
//->addConditionOn($question['question'], Form::FILLED)
//->setRequired('Vypňte odpověď A.');
$question->addText('answer_b', 'Odpověď B:');
$question->addText('answer_c', 'Odpověď C:');
$question->addText('answer_d', 'Odpověď D:');
//Multi answer
$question->addText('answer_a_multi', 'Odpověď A:');
//->addConditionOn($question['question'], Form::FILLED)
//->setRequired('Vypňte odpověď A.');
$question->addText('answer_b_multi', 'Odpověď B:');
$question->addText('answer_c_multi', 'Odpověď C:');
$question->addText('answer_d_multi', 'Odpověď D:');
$correctAnswers = array('a' => 'Odpověď A', 'b' => 'Odpověď B', 'c' => 'Odpověď C', 'd' => 'Odpověď D');
//Více správných odpovědí
$question->addCheckboxList('correct_answers', 'Správné odpovědi', $correctAnswers);
//Výběr jedné správné odpovědi
$question->addSelect('correct_answer', 'Správná odpověď: ', $correctAnswers);
//Text answer
$question->addText('answer_text', 'Přesná textová odpověď: ');
//Pro první otázku (validace)
if ($question->name == '0') {
$question['question']->setRequired('Vyplňte 1. otázku.');
}
$question->addSubmit('remove', '× Odstranit otázku')->setValidationScope(FALSE)->setAttribute('class', 'ajax')->onClick[] = array($this, 'removeElementClicked');
}, 2);
$questions->addSubmit('add', '+ Přidat otázku')->setValidationScope(FALSE)->setAttribute('class', 'btn btn-simple btn-add-question ajax')->onClick[] = array($this, 'addElementClicked');
$form->addSubmit('submit', 'Vytvořit test')->onClick[] = array($this, 'newTestFormFormSucceeded');
// $form->onSuccess[] = array($this, 'newTestFormFormSucceeded');
return $form;
}
示例6: createComponentEditEventForm
/**
* Form for editing the invitations to events
*
* @Action("edit")
* @Privilege("edit")
*/
protected function createComponentEditEventForm()
{
$form = new Form();
$form->addProtection('Vypršel časový limit, odešlete formulář znovu');
$form->addHidden('id');
$form->addText('name', 'Název akce:')->setRequired('Vyplňte název akce');
$form->addTextarea('text', 'Úvodní text lístečku:')->setRequired('Vyplňte text lístečku')->setAttribute('rows', 5);
$form->addDynamic('event_meeting', function (Container $container) {
$container->addText('comment', 'Typ srazu:');
$container->addDateTimePicker('starttime', 'Datum a čas srazu:')->setRequired('Vyplňte čas srazu');
$container->addText('startplace', 'Místo srazu:')->setRequired('Vyplňte místo srazu');
$container->addDateTimePicker('endtime', 'Datum a čas návratu:')->setRequired('Vyplňte čas návratu');
$container->addText('endplace', 'Místo návratu:')->setRequired('Vyplňte místo návratu');
$container->addSubmit('remove', 'X')->setValidationScope(FALSE)->addRemoveOnClick();
//intentional, delete after whole form submit
}, 1)->addSubmit('add', 'Přidat sraz')->setValidationScope(FALSE)->addCreateOnClick(TRUE);
$form->addTextarea('equipment', 'S sebou:')->setRequired('Vyplňte co si s sebou vzít na akci')->setAttribute('rows', 5);
$form->addTextarea('morse', 'Morseovka:')->setAttribute('rows', 5);
//contact person
$contacts = $this->registrations->findBy(['member_nickname IS NOT NULL'])->fetchPairs('member_nickname', 'member_nickname');
$form->addSelect('contactperson', 'Kontaktní osoba:', $contacts)->setRequired('Vyberte kontaktní osobu')->setPrompt('Kontaktní osoba');
if ($this->user->isAllowed('Admin:Default:Event', 'show')) {
$form->addCheckbox('showevent', 'Zobrazit lísteček')->setDefaultValue(TRUE);
}
$form->addSubmit('send', 'Změnit');
$form->onSuccess[] = $this->editEventFormSucceded;
return $form;
}