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


PHP Form::setValues方法代码示例

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


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

示例1: addBoardFormSucceded

 public function addBoardFormSucceded(Form $form, $values)
 {
     $user = UserService::loadFromSession($form->getPresenter()->getUser());
     if ($values->boardId == 0) {
         $newBoard = BoardService::create($values, $user);
     } else {
         $newBoard = BoardService::loadForUpdate($values->boardId, $values->content);
     }
     $this->boardFacade->save($newBoard);
     if ($form->getPresenter()->isAjax()) {
         if ($values->boardId == 0) {
             $form->setValues([], TRUE);
             $form->getPresenter()->redrawControl("addBoard");
         } else {
             $form->setValues(array("content" => $newBoard->content));
             $form->getPresenter()->getTemplate()->edit = true;
             $form->getPresenter()->redrawControl("editBoard");
         }
         $form->getPresenter()->setupPaginator();
         $form->getPresenter()->getTemplate()->boards = $this->boardFacade->findAll($form->getPresenter()->getLimit());
         $form->getPresenter()->redrawControl("boards");
         $form->getPresenter()->redrawControl("paginator");
     } else {
         $form->getPresenter()->redirect("this");
     }
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:26,代码来源:AddBoardForm.php

示例2: addCommentFormSucceded

 public function addCommentFormSucceded(Form $form)
 {
     $values = (object) $form->getHttpData();
     if (isset($values->antispam) && $values->antispam != $values->firstAddend + $values->secondAddend) {
         $form->getPresenter()->getTemplate()->wrongAntispam = true;
         $form->getPresenter()->getTemplate()->needsAntispam = true;
         $form->getPresenter()->redrawControl("wrongAntispam");
     } else {
         $articleId = $form->getPresenter()->getParameter("id");
         $user = UserService::loadFromSession($form->getPresenter()->getUser());
         $newComment = CommentService::create($values->content, $user);
         $this->commentFacade->save($newComment, $articleId);
         if ($this->commentFacade->needsAntispam($user)) {
             $form->getPresenter()->getTemplate()->needsAntispam = true;
             $form->getPresenter()->getTemplate()->firstAddend = Antispam::generate();
             $form->getPresenter()->getTemplate()->secondAddend = Antispam::generate();
         }
         if (!$form->getPresenter()->isAjax()) {
             $form->getPresenter()->redirect("this");
         } else {
             $form->getPresenter()->redrawControl("addCommentForm");
             $form->getPresenter()->redrawControl("comments");
             $form->getPresenter()->redrawControl("metainfoArea");
             $form->getPresenter()->redrawControl("metainfo");
             $form->setValues([], TRUE);
         }
     }
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:28,代码来源:AddCommentForm.php

示例3: createComponentServerProps

 /**
  * @return Nette\Application\UI\Form
  */
 protected function createComponentServerProps()
 {
     $form = new Form();
     $form->addTextArea('props', '', 70, 36);
     $form->addSubmit('submit', 'Nastavit')->setAttribute('class', 'ajax');
     try {
         $value = $this->fileModel->open($this->filePath, FALSE);
         $form->setValues(array('props' => implode('', $value)));
     } catch (\Nette\FileNotFoundException $e) {
         $form->setValues(array('props' => 'Soubor ještě nebyl vytvořen!'));
         $form['submit']->setDisabled();
     }
     if (!$this->allowedToEdit) {
         $form['submit']->setDisabled();
     }
     $form->onSuccess[] = $this->serverPropsFormSubmitted;
     return $form;
 }
开发者ID:VNovotna,项目名称:MP2014,代码行数:21,代码来源:FileEditor.php

示例4: taskFormSubmitted

 /**
  * @param  Nette\Application\UI\Form $form
  */
 public function taskFormSubmitted(Form $form)
 {
     $this->taskRepository->createTask($this->list->id, $form->values->text, $form->values->userId);
     $this->flashMessage('Úkol přidán.', 'success');
     if (!$this->isAjax()) {
         $this->redirect('this');
     }
     $form->setValues(array('userId' => $form->values->userId), TRUE);
     $this->invalidateControl('form');
     $this['taskList']->invalidateControl();
 }
开发者ID:nette,项目名称:tutorial-todo,代码行数:14,代码来源:TaskPresenter.php

示例5: createComponentForm

 /**
  * @return Form
  */
 public function createComponentForm()
 {
     $form = new Form();
     $form->addText(CF::NAME, 'Name:')->setRequired('Please enter your name.');
     $form->addText(CF::E_MAIL, 'Email:')->setRequired('Please enter your email.')->addRule(Form::EMAIL, 'Please enter valid email address.');
     $form->addText(CF::PHONE_NO, 'Phone no.:')->setRequired('Please enter your phone number.');
     $form->addText(CF::ADDRESS, 'Street:')->setRequired('Please enter your street.');
     $form->addText(CF::CITY, 'Ciy:')->setRequired('Please enter your city.');
     $form->addText(CF::POST_CODE, 'Postal code:')->setRequired('Please enter your postal code.');
     $form->addSelect(CF::COUNTRY_REGION_CODE, 'Country:', $this->cs->getPairs())->setRequired('Please select your country.')->setValue('FI');
     $form->addSubmit('send', 'Save');
     $form->setValues((array) $this->cus->Read($this->user->id));
     $form->onSuccess[] = array($this, 'formSucceeded');
     return $form;
 }
开发者ID:bagr001,项目名称:NAV_Shop,代码行数:18,代码来源:CustomerFormControl.php

示例6: messageFormSucceeded

 public function messageFormSucceeded(Form $form, $values)
 {
     if (trim($values->message) === '') {
         return;
     }
     $message = new Message();
     $message->text = $values->message;
     $message->course = $this->presenter->courseRegistry->course;
     $message->unit = $this->presenter->courseRegistry->unit;
     $message->user = $this->presenter->userInfo;
     $message->submitted_at = new DateTime();
     $this->messageRepository->persist($message);
     $this->generatedFilesStorage->remove($this->presenter->courseRegistry->course->id, 'html', '/chat/');
     $form->setValues(array(), TRUE);
     $this->redrawControl('chatForm');
 }
开发者ID:jan-martinek,项目名称:peer-blender,代码行数:16,代码来源:ChatControl.php

示例7: createComponentServerParams

 /**
  * @return Nette\Application\UI\Form
  */
 protected function createComponentServerParams()
 {
     $form = new Form();
     $form->addGroup('runtime');
     $form->addText('name', 'Jméno: ', 30, 20)->addRule(Form::FILLED, 'server musí mít jméno');
     $form->addText('path', 'Cesta: ', 30)->addRule(Form::FILLED, 'je nutné specifikovat cestu')->addRule(Form::PATTERN, "Toto není platná cesta ke složce, ty začínají a končí lomítkem.", "^/[^/].*/\$");
     $form->addText('executable', 'jméno .jar: ', 30)->addRule(Form::FILLED, 'je nutno specifikovat jméno .jar souboru');
     $form->addSubmit('update', 'Upravit')->setAttribute('class', 'ajax');
     if ($this->commonStorage) {
         $form['path']->setDisabled();
         $form['executable']->setDisabled();
     }
     if (!$this->user->isAllowed('server-settings', 'edit')) {
         $form['update']->setDisabled();
     }
     //defaults
     $values = $this->serverRepo->findById($this->selectedServerId)->fetch();
     $form->setValues($values);
     $form->onSuccess[] = $this->serverParamsFormSubmitted;
     return $form;
 }
开发者ID:VNovotna,项目名称:MP2014,代码行数:24,代码来源:GameSettingsPresenter.php

示例8: addCategoryFormSucceeded

 public function addCategoryFormSucceeded(Form $form, $values)
 {
     if ($values->categoryId == 0) {
         $values->rank = $this->categoryFacade->findMaxRank() + 1;
         $category = CategoryService::create($values);
     } else {
         $category = CategoryService::loadForUpdate($values);
     }
     $this->categoryFacade->save($category);
     if ($form->getPresenter()->isAjax()) {
         if ($values->categoryId == 0) {
             $form->setValues([], true);
             $form->getPresenter()->redrawControl("addCategoryForm");
         } else {
             $form->getPresenter()->getTemplate()->edit = true;
             $form->getPresenter()->redrawControl("editCategoryForm");
         }
         $form->getPresenter()->redrawControl("categories");
     } else {
         $form->getPresenter()->flashMessage("Nová kategorie byla úspěšně vytvořena.", "alert-success");
         $form->getPresenter()->redirect("this");
     }
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:23,代码来源:AddCategoryForm.php

示例9: changePasswordFormSucceeded

 /**
  * @param UI\Form $form
  */
 public function changePasswordFormSucceeded(UI\Form $form)
 {
     try {
         $values = $form->getValues();
         $this->userManager->changeUserPassword($values->old_password, $values->new_password, $this->user->identity->id);
         $form->setValues(array(), TRUE);
         $this->flashMessage('Your password change was successful.');
     } catch (\Aprila\InvalidArgumentException $e) {
         $this->flashMessage('Fill your current password correctly.', 'error');
     }
 }
开发者ID:aprila,项目名称:app-knowledge-base,代码行数:14,代码来源:UserSettingsPresenter.php

示例10: save

 /**
  * Pre-processing HTML obtained from CKEditor
  *
  * @param Form $form
  */
 public function save(Form $form)
 {
     $values = $form->getValues();
     $html = new Html();
     $html->setHtml($values['editor']);
     foreach ($html->getImages() as $image) {
         list($width, $height) = $image->getDimensionsFromStyle();
         $newFilename = substr($image->getSrc()->getFilename(), 0, strrpos($image->getSrc()->getFilename(), '.')) . "[{$width}x{$height}]" . substr($image->getSrc()->getFilename(), strrpos($image->getSrc()->getFilename(), '.'));
         $newSrc = $image->getSrc()->getPathinfo()->getPath() . '/' . self::TEMP_DIR_NAME . '/' . $newFilename;
         $imFile = realpath($this->publicDir . DIRECTORY_SEPARATOR . $image->getSrc()->getFilename());
         if ($imFile !== FALSE) {
             $im = Image::fromFile($imFile);
             // TODO: resize only if image is larger than real dimensions
             $im->resize($width, $height);
             if ($im->save($this->tempDir . DIRECTORY_SEPARATOR . $newFilename)) {
                 $image->setSrc($newSrc);
             }
         }
     }
     $values['editor'] = $html->getHtml();
     $form->setValues($values, TRUE);
     $this->onSuccess($form);
 }
开发者ID:snake-aas,项目名称:nette-ckeditor,代码行数:28,代码来源:NetteCKEditor.php

示例11: addSerialSucceeded

 public function addSerialSucceeded(Form $form, $values)
 {
     $values->byUser = $this->user->id;
     $this->articleManager->addSerial($values);
     $this->flashMessage('Přidáno');
     $form->setValues([], true);
     $form->setValues(['underSection' => $values->underSection, 'underSubSection' => $values->underSubSection]);
     $this->redrawAjax('section');
 }
开发者ID:kivi8,项目名称:ars-poetica,代码行数:9,代码来源:ArticlePresenter.php

示例12: setValues

 public function setValues($values, $erase = FALSE)
 {
     $values = Helpers::contractArray($values, $this->delimiter, TRUE);
     return parent::setValues($values, $erase);
 }
开发者ID:Vyki,项目名称:mva-dbm-example,代码行数:5,代码来源:MongoForm.php

示例13: newItemFormSubmitted


//.........这里部分代码省略.........
                 if ($key == 'email') {
                     continue;
                 }
                 $confItem = $this->pageConfig['form'][$key];
                 // if date is empty and this item is not mandatory
                 // also skip
                 if ($value == "" && (!isset($confItem['mandatory']) || !$confItem['mandatory'])) {
                     continue;
                 }
                 if ($confItem['type'] == 'calendar') {
                     // check for another conditions
                     if (!empty($this->pageConfig["form"][$key]["greaterEqualThen"])) {
                         $cond = $this->pageConfig["form"][$key]["greaterEqualThen"];
                         if (strtotime($values[$cond]) > strtotime($value)) {
                             $tmp = $value;
                             $value = $values[$cond];
                             $values[$cond] = $tmp;
                             $this->flashMessage('Akce nemůže skončit dříve než začne! Opravte prosím data.', 'error');
                             throw new Exception('badDateFormat');
                             // dump("gg");
                         }
                     }
                     $value = preg_replace('/\\s\\s+/', '', $value);
                     if ($this->itemRepository->isValidDate($value)) {
                         //$value = date('d.m.Y',$date)
                     } else {
                         $this->flashMessage('Zadali jste neplatné datum pro položku ' . $confItem['text'] . '!', 'error');
                         throw new Exception('badDateFormat');
                     }
                 }
             }
             unset($value);
             // get email and save it also to session
             if (isset($values->email)) {
                 $session = $this->getSession('agility');
                 $session->email = $values->email;
                 $email = $values->email;
             } else {
                 $email = '';
             }
             /** create hash for editing link */
             $hash = sha1(microtime() . $email);
             /** add new item to DB */
             $this->itemRepository->add($this->pageUrl, $hash, $this->pageConfig, $this->getHttpRequest(), $values);
             // also dont forget for calendar
             if (isset($this->pageConfig['settings']['calendar'])) {
                 // get from date
                 $dateFrom = date('Y-m-d', strtotime($values[$this->pageConfig['settings']['calendar']['from']]));
                 // get to date
                 if (isset($this->pageConfig['settings']['calendar']['to'])) {
                     // if TO is set
                     $dateTo = date('Y-m-d', strtotime($values[$this->pageConfig['settings']['calendar']['to']]));
                 } else {
                     if (isset($this->pageConfig['settings']['calendar']['duration'])) {
                         // if only duration is known
                         $dateTo = date('Y-m-d', strtotime($values[$this->pageConfig['settings']['calendar']['from']] . ' + ' . $values[$this->pageConfig['settings']['calendar']['duration']] . ' days'));
                     } else {
                         // if TO date is not set
                         $dateTo = NULL;
                     }
                 }
                 $this->calendarRepository->add($this->itemRepository->lastInsertId(), $dateFrom, $dateTo, $this->pageUrl);
             }
             /** auto delete items if wanted */
             if (isset($this->pageConfig['settings']['delete'])) {
                 $this->deleteOld();
             }
             /** sent email if it is enabled */
             if (!empty($this->pageConfig["settings"]["sendEmail"]) && $this->context->parameters['email']['send']) {
                 try {
                     $this->sendMail($this->context->parameters['email']['from'], $email, "Potvrzení nového záznamu", 'newItem', array('title' => $values->title, 'values' => $values, 'hash' => $hash));
                     $this->flashMessage($this->pageConfig["texts"]["successAdd"], 'success');
                 } catch (Exception $e) {
                     $this->flashMessage("Záznam byl uložen, ale došlo k chybě při odesílání emailu - pokud budete potřebovat upravit záznamy, kontaktujte nás na agility.tulak.me.", 'error');
                     \Nette\Diagnostics\Debugger::log('Email cannot be sent! ' . $e->getMessage());
                 }
             } else {
                 $this->flashMessage($this->pageConfig["texts"]["successAdd"], 'success');
             }
             // invalidate cache
             $cache = \Nette\Environment::getCache('Nette.Templating.Cache');
             $cache->clean(array(\Nette\Caching\Cache::TAGS => array('items/' . $this->pageUrl)));
             if (!$this->isAjax()) {
                 // $this->redirect('this');
             } else {
                 $this->invalidateControl('list');
                 $this->invalidateControl('form');
                 $form->setValues(array(), TRUE);
             }
             $this->redirect('Item:default', array('item' => $this->pageUrl));
         } catch (InvalidStateException $e) {
             $this->flashMessage($this->pageConfig["texts"]["failAdd"], 'error');
             throw $e;
         } catch (Exception $e) {
             if ($e->getMessage() != 'badDateFormat') {
                 throw $e;
             }
         }
     }
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:101,代码来源:ItemPresenter.php

示例14: formCommentSucceeded

 public function formCommentSucceeded(Form $form, $values)
 {
     $sub = $form->getHttpData();
     $under = isset($sub['subcomment']) && $sub['subcomment'] > 0 && $sub['subcomment'] !== '0' ? $sub['subcomment'] : false;
     if (!$this->user->isLoggedIn()) {
         try {
             $this->captchaManager->checkCaptcha($values->captcha);
             $this->captchaManager->setNewQuestion();
         } catch (\Exception $e) {
             if ($under !== false) {
                 $this->template->currentSubComment = $under;
             }
             $this->template->badAnswer = true;
             $this->flashMessage($e->getMessage() . ' Klikněte na: nová otázka');
             $this->redrawAjax(['captchaContainer', 'captchaStatic', 'flashMessageComment']);
             return;
         }
     }
     $this->commentsManager->addComment($values, $under);
     if ($under === false) {
         $this->setPage(1, true);
         $this->flashMessage('Přidán komentář');
         $this->redrawAjax('commentContainerAll');
     } else {
         $this->template->currentSubComment = $under;
         $this->flashMessage('Přidán podkomentář');
         $this->redrawAjax('commentContainerAll');
     }
     $this->redrawAjax(['captchaContainer', 'captchaStatic', 'flashMessageComment']);
     $form->setValues([], true);
 }
开发者ID:kivi8,项目名称:ars-poetica,代码行数:31,代码来源:CommentsControl.php


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