當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。