• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Forms\Form类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onSubmit

 public function onSubmit(Form $form)
 {
     $data = $form->getValues();
     // Předáme data do šablony
     $this->template->values = $data;
     $queueId = uniqid();
     \dibi::begin();
     $gallery_id = $this->gallery->insert(array("name" => $data["name"]));
     // Přesumene uploadované soubory
     foreach ($data["upload"] as $file) {
         // $file je instance HttpUploadedFile
         $newFilePath = FILESTORAGE_DIR . "/q{" . $queueId . "}__f{" . rand(10, 99) . "}__" . $file->getName();
         // V produkčním módu nepřesunujeme soubory...
         if (!Environment::isProduction()) {
             if ($file->move($newFilePath)) {
                 $this->flashMessage("Soubor " . $file->getName() . " byl úspěšně přesunut!");
             } else {
                 $this->flashMessage("Při přesouvání souboru " . $file->getName() . " nastala chyba! Pro více informací se podívejte do logů.");
             }
         }
         $this->files->insert($file);
         $this->gallery->addFile($gallery_id, $file_id);
         dump($file);
     }
     \dibi::commit();
 }
开发者ID:soundake,项目名称:pd,代码行数:26,代码来源:GalleryJoinPresenter.php


示例2: saveEvent

 public function saveEvent(Form $form)
 {
     $values = $form->getValues();
     if ($form['save']->isSubmittedBy()) {
         $categories = $values['categories'];
         unset($values['categories']);
         if ($form->onSuccess) {
             unset($values['agree']);
             $values['user_id'] = $this->user->loggedIn ? $this->user->id : null;
             $values['subject_id'] = 1;
             // anonymní akce // anonymní subjekt
             $values['approved'] = 0;
             $values['visible'] = 1;
             $values['reviewed'] = 0;
             $pd = $this->context->createService('events')->insert($values);
             $id = $pd->id;
             $this->flashMessage('Akce uložena do zásobníku', 'success');
             \dibi::begin();
             foreach ($categories as $n) {
                 \dibi::query('INSERT INTO [event_x_category] SET [event_id]=%i', $id, ', [category_id]=%i', $n);
             }
             \dibi::commit();
         }
         $form->addError('Something bad happend.');
     }
     $this->redirect('upload-photos', array('event_id' => $id));
 }
开发者ID:soundake,项目名称:pd,代码行数:27,代码来源:AddPresenter.php


示例3: formSuccess

 public function formSuccess(Form $form, $values)
 {
     $t = $this->getTranslator();
     try {
         $this->user->login($values->login, $values->password);
         $this->fireEvent('onLogin', [$this->user->id]);
         //$this->onLogin($this->user->id);
         $this->presenter->redirect('this');
     } catch (ZaxCMS\Security\UserLoginDisabledException $ex) {
         $form->addError($t->translate('auth.error.loginDisabled'));
     } catch (ZaxCMS\Security\InvalidCredentialsException $ex) {
         if ($this->groupLoginPasswordErrors) {
             $form['login']->addError('');
             $form['password']->addError($t->translate('auth.error.invalidCredentials'));
         } else {
             if ($ex instanceof ZaxCMS\Security\InvalidEmailException) {
                 $form['login']->addError($t->translate('auth.error.invalidEmail'));
             } else {
                 if ($ex instanceof ZaxCMS\Security\InvalidNameException) {
                     $form['login']->addError($t->translate('auth.error.invalidName'));
                 } else {
                     if ($ex instanceof ZaxCMS\Security\InvalidPasswordException) {
                         $form['password']->addError($t->translate('auth.error.invalidPassword'));
                     }
                 }
             }
         }
     } catch (ZaxCMS\Security\UnverifiedUserException $ex) {
         $form->addError($t->translate('auth.error.unverifiedUser'));
     } catch (ZaxCMS\Security\BannedUserException $ex) {
         $form->addError($t->translate('auth.error.bannedUser'));
     } catch (ZaxCMS\Security\AuthenticationException $ex) {
         $this->onError($ex);
     }
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:35,代码来源:LoginFormControl.php


示例4: renderFormEnd

 /**
  * Renders form end.
  * @return string
  */
 public static function renderFormEnd(Form $form)
 {
     $s = '';
     if (strcasecmp($form->getMethod(), 'get') === 0) {
         $url = explode('?', $form->getElementPrototype()->action, 2);
         if (isset($url[1])) {
             list($url[1]) = explode('#', $url[1], 2);
             foreach (preg_split('#[;&]#', $url[1]) as $param) {
                 $parts = explode('=', $param, 2);
                 $name = urldecode($parts[0]);
                 if (!isset($form[$name])) {
                     $s .= Nette\Utils\Html::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1])));
                 }
             }
         }
     }
     foreach ($form->getComponents(TRUE, 'Nette\\Forms\\Controls\\HiddenField') as $control) {
         if (!$control->getOption('rendered')) {
             $s .= $control->getControl();
         }
     }
     if (iterator_count($form->getComponents(TRUE, 'Nette\\Forms\\Controls\\TextInput')) < 2) {
         $s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->';
     }
     echo ($s ? "<div>{$s}</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n";
 }
开发者ID:genextwebs,项目名称:dropbox-sample,代码行数:30,代码来源:FormMacros.php


示例5: testAddFormControl

 public function testAddFormControl()
 {
     $this->form->expects($this->once())->method('addCheckbox')->with('var', 'Boolean')->will($this->returnValue($this->control));
     $this->control->expects($this->any())->method('setRequiered')->will($this->returnValue($this->control));
     $result = $this->object->addFormControl($this->form, $this->metadata);
     $this->assertSame($this->control, $result);
 }
开发者ID:voda,项目名称:formbuilder,代码行数:7,代码来源:BooleanMapperTest.php


示例6: setupForm

 protected function setupForm(Form $form)
 {
     $form->addText('name', 'Name')->setRequired();
     $form->addTextArea('content', 'Content')->setAttribute('class', 'editor-standard');
     $form->addCheckbox('active', 'Active');
     $form->addSubmit('submit', 'Submit');
 }
开发者ID:04EO,项目名称:TrainingTaskNette,代码行数:7,代码来源:PageFormFactory.php


示例7: addFormControl

 public function addFormControl(\Nette\Forms\Form $form, Builder\Metadata $meta)
 {
     $input = new \Vodacek\Forms\Controls\DateInput($meta->label, $meta->type);
     $form->addComponent($input, $meta->name);
     $this->addConditions($input, $meta->conditions);
     return $input;
 }
开发者ID:voda,项目名称:formbuilder,代码行数:7,代码来源:DateMapper.php


示例8: renderFormBegin

 /**
  * Renders form begin.
  * @param Form $form
  * @param array $attrs
  * @param bool $withTags
  * @return string
  */
 public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
 {
     $renderer = $form->getRenderer();
     if ($renderer instanceof IManualRenderer) {
         $renderer->beforeRender($form);
     }
     return parent::renderFormBegin($form, $attrs, $withTags);
 }
开发者ID:pipaslot,项目名称:forms,代码行数:15,代码来源:Runtime.php


示例9: testAddFormControl

 public function testAddFormControl()
 {
     $values = array('foo' => 'bar', 'baz' => 'qux');
     $this->object = $this->getMockBuilder('\\Vodacek\\Form\\Builder\\Mappers\\SelectboxMapper')->setMethods(array('getValues'))->getMockForAbstractClass();
     $this->object->expects($this->any())->method('getValues')->will($this->returnValue($values));
     $this->form->expects($this->any())->method('addSelect')->with('var', 'Select', $values)->will($this->returnValue($this->control));
     $this->object->addFormControl($this->form, $this->metadata);
 }
开发者ID:voda,项目名称:formbuilder,代码行数:8,代码来源:SelectboxMapperTest.php


示例10: testAddFloatWithCustomStep

 public function testAddFloatWithCustomStep()
 {
     $this->metadata->type = 'float';
     $this->metadata->custom['step'] = '0.002';
     $this->form->expects($this->once())->method('addText')->with('var', 'Int')->will($this->returnValue($this->control));
     $this->controlPrototype->expects($this->any())->method('type')->with('number');
     $this->controlPrototype->expects($this->any())->method('step')->with('0.002');
     $this->object->addFormControl($this->form, $this->metadata);
 }
开发者ID:voda,项目名称:formbuilder,代码行数:9,代码来源:NumberMapperTest.php


示例11: render

 public function render(\Nette\Forms\Form $form, $mode = null)
 {
     $content = Html::el('div class="details"');
     foreach ($form->getGroups() as $group) {
         if (!$group->getControls() || !$group->getOption('visual')) {
             continue;
         }
         $elgroup = $content->create('div class="viewGroup"');
         $grouplabel = $group->getOption('label');
         if (!is_string($grouplabel)) {
             $grouplabel = $grouplabel->getText();
         }
         $elgroup->create('h5', $grouplabel);
         $el = $elgroup->create('dl');
         foreach ($group->getControls() as $control) {
             if ($control instanceof \Nette\Forms\Controls\HiddenField || $control instanceof \Nette\Forms\Controls\Button) {
                 continue;
             }
             $label = $control->getLabel();
             if (!is_string($label)) {
                 $label = $label->getText();
             }
             $el->create('dt', $label);
             $value = $control->getValue();
             if ($control instanceof \Nette\Forms\Controls\Checkbox) {
                 if ($value) {
                     $el->create('dd')->create('span class="yes"');
                 } else {
                     $el->create('dd')->create('span class="no"');
                 }
             } elseif ($control instanceof \Nette\Forms\Controls\SelectBox) {
                 $items = FlatArray::getLeafs($control->getItems());
                 if (!isset($items[$value])) {
                     $el->create('dd class="na"', 'n/a');
                     continue;
                 }
                 $value = $items[$value];
                 if (!is_string($value)) {
                     $value = $value->getTitle();
                 }
                 $el->create('dd', $value);
             } else {
                 if ($value instanceof \Nette\DateTime) {
                     $value = $value->format('j.n.Y');
                 }
                 if ($value !== '') {
                     $el->create('dd', $value);
                 } else {
                     $el->create('dd class="na"', 'n/a');
                 }
             }
         }
         $elgroup->create('div style="{clear: both;}"');
     }
     return $content;
 }
开发者ID:hleumas,项目名称:databaza,代码行数:56,代码来源:DisplayRenderer.php


示例12: decorateFormControls

 private function decorateFormControls()
 {
     $this->form->getElementPrototype()->class('form-horizontal');
     $this->usedPrimary = FALSE;
     foreach ($this->form->getControls() as $control) {
         if ($control instanceof NetteBaseControl) {
             $this->decorateFormControl($control);
         }
     }
 }
开发者ID:achse,项目名称:bootstrap3-form-decorator,代码行数:10,代码来源:Bootstrap3FormDecorator.php


示例13: testRegistration

 public function testRegistration()
 {
     UploadControl::register();
     $form = new Forms\Form();
     $control = $form->addAttachment('file', 'File');
     $this->assertInstanceOf('Karzac\\Forms\\UploadControl', $control);
     $this->assertSame('file', $control->getName());
     $this->assertSame('File', $control->caption);
     $this->assertSame($form, $control->getForm());
 }
开发者ID:karzac,项目名称:bootstrap-upload-control,代码行数:10,代码来源:UploadControlTest.php


示例14: savePassword

 public function savePassword(Form $form)
 {
     $values = $form->getValues();
     try {
         $this->item->update(array('password' => hash("sha512", $values->prvniheslo . str_repeat('mooow', 10)), 'generated_password' => 0));
         $this->flashMessage('Password saved', 'success');
         $this->redirect('User:');
     } catch (Nette\InvalidArgumentException $e) {
         $this->flashMessage($e, 'error');
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:11,代码来源:UserPresenter.php


示例15: loginFormSucceded

 public function loginFormSucceded(Form $form, $values)
 {
     $settings = $this->EntityManager->getRepository(Settings::getClassName());
     $setting = $settings->find(1);
     if ($setting->admin_login == $values['login'] and $setting->admin_pass == md5($values['pass'])) {
         $this->getUser()->login($setting->admin_login, $setting->admin_pass);
         $this->redirect('Homepage:');
     } else {
         $form->addError('Špatně zadaný login nebo heslo!');
     }
 }
开发者ID:B4rtosek,项目名称:sislak,代码行数:11,代码来源:LoginPresenter.php


示例16: savePassword

 public function savePassword(Form $form)
 {
     $values = $form->getValues();
     try {
         $users = $this->context->createServiceUsers();
         $users->get($this->user->id)->update(array('password' => $users->calculateHash($values['prvniheslo']), 'generated_password' => 0));
         $this->flashMessage('Password saved', 'success');
         $this->redirect('User:');
     } catch (\Nette\InvalidArgumentException $e) {
         $this->flashMessage($e, 'error');
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:12,代码来源:UserPresenter.php


示例17: ApplyBootstrapToControls

 /**
  * @param Form $form
  */
 public static function ApplyBootstrapToControls(Form $form)
 {
     $usedPrimary = FALSE;
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
 }
开发者ID:pipaslot,项目名称:forms,代码行数:17,代码来源:BootstrapHelper.php


示例18: aktualityFormSuccess

 public function aktualityFormSuccess(Nette\Forms\Form $form)
 {
     $values = $form->getValues();
     $aktualitaId = $this->getParameter('id');
     if ($aktualitaId) {
         //Debugger::fireLog('editace');
         $this->aktualityModel->updateAktuality($aktualitaId, $values);
         $this->flashMessage("aktualita " . $values['name'] . " byla upravena");
         $this->redirect('Aktuality:prehledAktualit');
     } else {
         $this->aktualityModel->newAktualita($values);
         $this->flashMessage("Aktualita vložena");
         $this->redirect('Aktuality:prehledAktualit');
     }
 }
开发者ID:re1la2pse,项目名称:detinsky_projekt,代码行数:15,代码来源:AktualityPresenter.php


示例19: render

 /**
  * @param \Nette\Forms\Form $form
  * @param string|null $mode
  * @return string
  */
 public function render(Nette\Forms\Form $form, $mode = null)
 {
     $form->getElementPrototype()->class[] = 'form-horizontal';
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->setAttribute('class', empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = true;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->setAttribute('class', 'form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->class($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
开发者ID:venne,项目名称:venne,代码行数:20,代码来源:Bootstrap3Renderer.php


示例20: render

 public function render(Forms\Form $form, $mode = NULL)
 {
     $form->getElementPrototype()->class('form-horizontal')->novalidate(TRUE);
     foreach ($form->getControls() as $control) {
         if ($control instanceof Controls\Button) {
             $control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
             $usedPrimary = TRUE;
         } elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
             $control->getControlPrototype()->addClass('form-control');
         } elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
             $control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
         }
     }
     return parent::render($form, $mode);
 }
开发者ID:milo,项目名称:web-project,代码行数:15,代码来源:BootstrapRenderer.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Forms\Helpers类代码示例发布时间:2022-05-23
下一篇:
PHP Forms\Container类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap