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


PHP Forms\Form类代码示例

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


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


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