当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::setDefaults方法代码示例

本文整理汇总了PHP中Nette\Application\UI\Form::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setDefaults方法的具体用法?PHP Form::setDefaults怎么用?PHP Form::setDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Application\UI\Form的用法示例。


在下文中一共展示了Form::setDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * @return \Nette\Application\UI\Form
  */
 public function create()
 {
     $form = new Form();
     $form->addGroup($this->user ? 'Upravit uživatele' : 'Přidat uživatele');
     $form->addText("name", 'Jméno:')->setRequired('Vyplňte jméno');
     $form->addText("email", 'Email:')->setRequired('Vyplňte email')->addRule(function ($ctrl) {
         if ($this->user and $this->user->email == $ctrl->getValue()) {
             return TRUE;
         }
         return (bool) (!$this->userFacade->findUserByEmail($ctrl->getValue()));
     }, 'Email je obsazen, zvolte prosím jiný');
     $password = $form->addPassword("password", 'Heslo:');
     $password2 = $form->addPassword("password2", 'Heslo znovu:');
     if (!$this->user) {
         $password->setRequired('Vyplňte heslo');
         $password2->addRule(Form::FILLED, 'Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
     } else {
         $password2->addConditionOn($password, Form::FILLED)->setRequired('Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
     }
     $form->addSubmit("send", $this->user ? 'Upravit uživatele' : 'Přidat uživatele');
     $form->setRenderer(new Bs3FormRenderer());
     $form->onSuccess[] = $this->processForm;
     if ($this->user) {
         $form->setDefaults(["name" => $this->user->name, "email" => $this->user->email]);
     }
     return $form;
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:30,代码来源:SetUserForm.php

示例2: createComponentForm

 public function createComponentForm($name)
 {
     $form = new Form($this, $name);
     $form->addTextArea("html", "Upravte data", 80, 50)->controlPrototype->class[] = "tinymce";
     $form->addSubmit("doPDFka", "Do PDFka!");
     $appDir = Nette\Environment::getVariable('appDir');
     $form->setDefaults(array("html" => $this->createTemplate()->setFile($appDir . "/templates/Homepage/pdf-source.latte")->__toString()));
     $form->onSuccess[] = array($this, "onSubmit");
 }
开发者ID:jkuchar,项目名称:pdfresponse-example,代码行数:9,代码来源:HomepagePresenter.php

示例3: create

 public function create()
 {
     $form = new Form();
     $form->addGroup("Set base title");
     $form->addText("baseTitle", "Base title:");
     $form->addSubmit("send", "Set base title");
     $form->onSuccess[] = $this->processForm;
     $form->setDefaults(array("baseTitle" => $this->settingsDao->getBaseTitle()));
     return $form;
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:10,代码来源:SetBaseTitle.php

示例4: create

 public function create()
 {
     $form = new Form();
     $form->addGroup("Set Google Analytics key");
     $form->addText("key", "Google Analytics api key:")->setRequired('Fill Google Analytics api key');
     $form->addSubmit("send", "Set Google Analytics key");
     $form->onSuccess[] = $this->processForm;
     $form->setDefaults(array("key" => $this->settingsDao->getGoogleAnalyticsKey()));
     return $form;
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:10,代码来源:SetGoogleAnalytics.php

示例5: create

 public function create()
 {
     $form = new Form();
     $form->addGroup("Set robots.txt");
     $form->addTextArea("robots", "Robots.txt content:");
     $form->addSubmit("send", "Set robots.txt");
     $form->onSuccess[] = $this->processForm;
     $form->setDefaults(array("robots" => $this->settingsDao->getRobots()));
     return $form;
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:10,代码来源:SetRobots.php

示例6: createComponentFormExcelParser

 protected function createComponentFormExcelParser()
 {
     $form = new Form();
     $form->addTextarea('clipboard', 'Clipboard:');
     $form->addTextarea('template', 'Template:');
     $form->addSubmit('generate', 'Generate');
     $form->onSuccess[] = callback($this, 'excelParserFormSubmitted');
     $form->setDefaults(array('template' => '{{index}}: {{0}}'));
     return $form;
 }
开发者ID:Aprila,项目名称:app-developer-desktop,代码行数:10,代码来源:ClipboardPresenter.php

示例7: createComponentConsoleForm

 protected function createComponentConsoleForm()
 {
     $form = new Form();
     $defaults = [];
     $form->setRenderer(new BootstrapRenderer());
     $uri = $this->request->getUrl();
     $scheme = $uri->scheme;
     if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
         $scheme = $_SERVER['HTTP_X_FORWARDED_PROTO'];
     }
     $port = '';
     if ($uri->scheme == 'http' && $uri->port != 80) {
         $port = ':' . $uri->port;
     }
     $url = $scheme . '://' . $uri->host . $port . '/api/' . $this->endpoint->getUrl();
     $form->addText('api_url', 'Api Url');
     $defaults['api_url'] = $url;
     $form->addText('method', 'Method');
     $defaults['method'] = $this->endpoint->getMethod();
     if ($this->authorization instanceof BearerTokenAuthorization) {
         $form->addText('token', 'Token')->setAttribute('placeholder', 'Enter token');
     } elseif ($this->authorization instanceof NoAuthorization) {
         $form->addText('authorization', 'Authorization')->setDisabled(true);
         $defaults['authorization'] = 'No authorization - global access';
     }
     $params = $this->handler->params();
     foreach ($params as $param) {
         $count = $param->isMulti() ? 5 : 1;
         for ($i = 0; $i < $count; $i++) {
             $key = $param->getKey();
             if ($param->isMulti()) {
                 $key = $key . '___' . $i;
             }
             if ($param->getAvailableValues() && is_array($param->getAvailableValues())) {
                 $c = $form->addSelect($key, $this->getParamLabel($param), array_combine($param->getAvailableValues(), $param->getAvailableValues()));
                 if (!$param->isRequired()) {
                     $c->setPrompt('Select ' . $this->getLabel($param));
                 }
             } elseif ($param->getAvailableValues() && is_string($param->getAvailableValues())) {
                 $c = $form->addText($key, $this->getParamLabel($param))->setDisabled(true);
                 $defaults[$key] = $param->getAvailableValues();
             } elseif ($param->getType() == InputParam::TYPE_FILE) {
                 $c = $form->addUpload($key, $this->getParamLabel($param));
             } elseif ($param->getType() == InputParam::TYPE_POST_RAW) {
                 $c = $form->addTextArea('post_raw', $this->getParamLabel($param))->setAttribute('rows', 10);
             } else {
                 $c = $form->addText($key, $this->getParamLabel($param));
             }
         }
     }
     $form->addSubmit('send', 'Otestuj')->getControlPrototype()->setName('button')->setHtml('<i class="fa fa-cloud-upload"></i> Try api');
     $form->setDefaults($defaults);
     $form->onSuccess[] = array($this, 'formSucceeded');
     return $form;
 }
开发者ID:tomaj,项目名称:nette-api,代码行数:55,代码来源:ApiConsoleControl.php

示例8: createComponentObjectForm

 public function createComponentObjectForm()
 {
     $form = new Form();
     $form->addText('name', 'Tag:', NULL, 200)->setRequired();
     if ($this->detailObject) {
         $form->setDefaults(['name' => $this->detailObject->name]);
     }
     $form->addSubmit('actionSend', 'Save');
     $form->onSuccess[] = array($this, 'objectFormSubmitted');
     return $form;
 }
开发者ID:Aprila,项目名称:laboratory,代码行数:11,代码来源:SimpleExamplePresenter.php

示例9: createComponentForm

 /**
  * @return Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->class('navbar-form navbar-right');
     $form->addText('positive_votes', 'Positive votes to merge')->setRequired('%label is require')->addRule(Form::INTEGER, '%label has to be an integer');
     $form->addCheckbox('delete_source_branch', 'Remove source branch when merge request is accepted');
     $form->addSubmit('save', 'Save');
     $form->onSuccess[] = $this->formSuccess;
     if ($this->project) {
         $form->setDefaults($this->project);
     }
     return $form;
 }
开发者ID:ricco24,项目名称:gitlab-auto-merger,代码行数:16,代码来源:ProjectForm.php

示例10: createComponentForm

 protected function createComponentForm()
 {
     $form = new UI\Form();
     $form->addProtection();
     $form->addText('username', 'Uživatelské přihlašovací jméno:')->setRequired('Zadejte prosím přihlašovací jméno.');
     $form->addPassword('password', 'Nové heslo k tomuto účtu:')->setRequired('Zadejte prosím své stávající, nebo nové heslo.');
     //TODO: toto bude zapotřebí předělat
     if ($this->presenter->user->isInRole('admin')) {
         $role = ['admin' => 'Administrátor', 'demo' => 'Demo účet'];
         $form->addSelect('role', 'Role:', $role);
     } else {
         $role = ['demo' => 'Demo účet'];
         $form->addSelect('role', 'Role:', $role);
     }
     if ($this->account) {
         $form->setDefaults(['username' => $this->account->username]);
     } else {
         $form->setDefaults(['role' => 'demo']);
     }
     $form->addSubmit('save', 'Uložit změny');
     $form->onSuccess[] = $this->formSucceeded;
     return $form;
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:23,代码来源:UserEditForm.php

示例11: create

 /**
  * @return \Nette\Application\UI\Form
  */
 public function create()
 {
     $form = new Form();
     $form->addGroup($this->performance ? "Upravit představení" : "Přidat představení");
     $form->addTextArea("songAuthor", "Autor skladby:")->setRequired("Vyplňte prosím autora skladby");
     $form->addTextArea("songName", "Jméno skladby:")->setRequired("Vyplňte prosím jméno skladby");
     $form->addTextArea("note", "Poznámka:");
     $form->addSubmit("send", $this->performance ? "Upravit představení" : "Přidat představení");
     $form->onSuccess[] = $this->processForm;
     if ($this->performance) {
         $form->setDefaults(["songAuthor" => $this->performance->songAuthor, "songName" => $this->performance->songName, "note" => $this->performance->note]);
     }
     return $form;
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:17,代码来源:SetPerformanceForm.php

示例12: createComponentPageForm

 protected function createComponentPageForm()
 {
     $form = new UI\Form();
     $form->addProtection();
     $form->addText('title', 'Název:')->setRequired('Je zapotřebí vyplnit název stránky.');
     $form->addText('slug', 'URL slug:')->setRequired('Je zapotřebí vyplnit slug.');
     $form->addTextArea('editor', 'Obsah stránky:')->setHtmlId('editor')->setRequired('Je zapotřebí napsat nějaký text.');
     if ($this->page) {
         $form->setDefaults(['title' => $this->page->title, 'slug' => $this->page->slug, 'editor' => $this->page->body]);
     }
     $form->addSubmit('save', 'Uložit a publikovat');
     $form->onSuccess[] = $this->pageFormSucceeded;
     return $form;
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:14,代码来源:PageForm.php

示例13: create

 /**
  * @return Form
  */
 public function create()
 {
     $form = new Form();
     $form->addGroup();
     $form->addText('username', 'Login:')->setRequired('Zadejte prosím uživatelské jméno.');
     $form->addPassword('password', 'Heslo:')->setRequired('Zadejte prosím heslo.');
     $form->addCheckbox('remember', 'Zůstat přihlášen');
     $form->addGroup();
     $form->addSubmit('send', 'Přihlásit');
     $form->addSubmit('cancel', 'Zpět')->setValidationScope(FALSE);
     $form->setDefaults(array('username' => 'user', 'password' => NULL, 'remember' => TRUE));
     $form->onSuccess[] = array($this, 'formSucceeded');
     $form->setRenderer(new Bs3FormRenderer());
     return $form;
 }
开发者ID:horakmar,项目名称:gorgon,代码行数:18,代码来源:SignFormFactory.php

示例14: createComponentAlbumForm

 /**
  * @param string $name
  */
 public function createComponentAlbumForm($name)
 {
     $form = new Form($this, $name);
     $form->addText('artist', 'Artist')->setRequired();
     $form->addText('albumName', 'Album name')->setRequired();
     $form->addText('year', 'Year')->setRequired()->addRule(Form::INTEGER);
     if ($this->album) {
         $form->setDefaults(['artist' => $this->album->getArtist(), 'albumName' => $this->album->getAlbumName(), 'year' => $this->album->getYear()]);
         $form->addSubmit('save', 'Edit album');
         $form->onSuccess[] = $this->successEditAlbumForm;
     } else {
         $form->addSubmit('save', 'Add new album');
         $form->onSuccess[] = $this->successAddAlbumForm;
     }
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:18,代码来源:AlbumControl.php

示例15: createComponentForm

 /**
  * @return Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->getElementPrototype()->class('navbar-form navbar-right');
     $form->addText('gitlab_url', 'Gitlab API URL')->setAttribute('placeholder', 'https://domain/api/v3');
     $form->addText('gitlab_merger_url', 'GitlabMerger URL');
     $form->addText('token', 'Automerger user access token');
     $form->addSubmit('save', 'Save');
     $form->onSuccess[] = $this->formSuccess;
     $data = $this->settingsRepository->fetch();
     if ($data) {
         $form->setDefaults($data);
     }
     return $form;
 }
开发者ID:ricco24,项目名称:gitlab-auto-merger,代码行数:18,代码来源:SettingsForm.php


注:本文中的Nette\Application\UI\Form::setDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。