Author: David Grudl
Inheritance: extends TextBase
コード例 #1
0
ファイル: BaseForm.php プロジェクト: bazo/translation-ui
 /**
  *
  * @param string $name
  * @param string $label
  * @return Html5Input
  */
 public function addEmail($name, $label = NULL)
 {
     $input = new \Nette\Forms\Controls\TextInput($label);
     $input->type = 'email';
     $input->addCondition(Form::FILLED)->addRule(Form::EMAIL, '%label must be a valid email');
     return $this[$name] = $input;
 }
コード例 #2
0
ファイル: PrivilegePresenter.php プロジェクト: vsek/base
 public function valideFormNewSystemName(\Nette\Forms\Controls\TextInput $input)
 {
     $privilege = $this->privileges->where('system_name', $input->getValue());
     if (!$privilege->fetch()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
 /**
  * Create control from configuration or return NULL if factory does not match config.
  *
  * @param IControlConfig $config
  * @return NULL|BaseControl
  */
 public function createControl(IControlConfig $config)
 {
     switch ($config->getType()) {
         case IControlConfig::BUTTON:
             return new Controls\Button($config->getLabel());
         case IControlConfig::CHECKBOX:
             return new Controls\Checkbox($config->getLabel());
         case IControlConfig::EMAIL:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('email');
             return $input;
         case IControlConfig::HIDDEN:
             return new Controls\HiddenField();
         case IControlConfig::PASSWORD:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('password');
             return $input;
         case IControlConfig::SUBMIT:
             return new Controls\SubmitButton($config->getLabel());
         case IControlConfig::TEXT:
             return new Controls\TextInput($config->getLabel());
         case IControlConfig::TEXTAREA:
             return new Controls\TextArea($config->getLabel());
         case IControlConfig::DATE_TIME:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::DATE:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::TIME:
             $input = new Controls\TextInput($config->getLabel());
             return $input;
         case IControlConfig::URL:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('url');
             return $input;
         case IControlConfig::INTEGER:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('number');
             return $input;
         case IControlConfig::FLOAT:
             $input = new Controls\TextInput($config->getLabel());
             $input->setType('number');
             $input->setAttribute('step', 'any');
             return $input;
     }
     return new Nette\Forms\Controls\TextInput($config->getLabel());
 }
コード例 #4
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->class = 'text datepicker';
     $control->autocomplete = 'off';
     return $control;
 }
コード例 #5
0
ファイル: TextWithSelect.php プロジェクト: venne/venne
 /**
  * Generates control's HTML element.
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $container = clone $this->container;
     $container->add(' <div class="input-group">' . parent::getControl());
     $dest = '';
     $s = null;
     foreach ($this->items as $key => $value) {
         if (!is_array($value)) {
             $value = array($key => $value);
         }
         foreach ($value as $key2 => $value2) {
             if ($value2 instanceof \Nette\Utils\Html) {
                 $dest .= '<li><a href="#">' . $value2 . '</a></li>';
             } else {
                 $key2 = $this->useKeys ? $key2 : $value2;
                 $value2 = $this->translate((string) $value2);
                 if ($key2 == $this->value) {
                     $s = $value2;
                 }
                 $dest .= '<li><a href="#">' . $value2 . '</a></li>';
             }
         }
     }
     $container->add('<div class="input-group-btn">
     <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"><span class="textWithSelect-text">' . $s . '</span> <span class="caret"></span></button>
     <ul class="dropdown-menu pull-right">');
     $container->add($dest);
     $container->add('</div></div>');
     return $container;
 }
コード例 #6
0
ファイル: NumberMapperTest.php プロジェクト: voda/formbuilder
 /**
  * @dataProvider dp_testToPropertyValueWithFloats
  */
 public function testToPropertyValueWithFloats($value, $expected)
 {
     $this->metadata->type = 'float';
     $this->control->expects($this->any())->method('getValue')->will($this->returnValue($value));
     $result = $this->object->toPropertyValue($this->control, $this->metadata);
     $this->assertSame($expected, $result);
 }
コード例 #7
0
ファイル: MoneyControl.php プロジェクト: f3l1x/nette-plugins
 /**
  * Sets control's value.
  *
  * @param $value
  * @return MoneyControl
  * @override
  */
 public function setValue($value)
 {
     foreach ($this->filtersIn as $filter) {
         $value = $filter($value);
     }
     return parent::setValue($value);
 }
コード例 #8
0
ファイル: TagControl.php プロジェクト: pipaslot/forms
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->value = implode(",", (array) $this->getValue());
     $control->addAttributes(array("data-role" => "tagsinput"));
     return $control;
 }
コード例 #9
0
ファイル: DateTimePicker.php プロジェクト: cujan/vcelyweb
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->class = 'datetimepicker form-control';
     $control->readonly = TRUE;
     return $control;
 }
コード例 #10
0
ファイル: DisplayablePassword.php プロジェクト: instante/ui
 /**
  * @inheritdoc
  * @return Html
  */
 public function getControl()
 {
     $control = clone $this->fullControl;
     $control->insert(0, parent::getControl());
     // the original text input control is injected only there
     return $control;
 }
コード例 #11
0
ファイル: TbDatePicker.php プロジェクト: bombush/NatsuCon
 /**
  * Sets date
  *
  * @param string $value date
  * @return void
  */
 public function setValue($value)
 {
     if ($value instanceof \DateTime) {
         $value = $value->format($this->format);
     }
     parent::setValue($value);
 }
コード例 #12
0
ファイル: PswdInput.php プロジェクト: lohini/framework
 /**
  * Generates control's HTML element
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl()->addClass('pswdinput');
     $this->data['fid'] = $this->getForm()->getElementPrototype()->id;
     $control->data('lohini-pswd', \Nette\Utils\Json::encode(array_filter($this->data)));
     return Html::el('span', ['style' => 'position: relative; float: left;'])->add($control);
 }
コード例 #13
0
ファイル: Html5Input.php プロジェクト: bazo/Tatami
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     $this->operation = $operation;
     if ($operation === Form::FLOAT) {
         $this->addFilter(callback(__CLASS__, 'filterFloat'));
     }
     return parent::addRule($operation, $message, $arg);
 }
コード例 #14
0
 /**
  * Sets control's value.
  * @param  string
  * @return self
  */
 public function setValue($value = null)
 {
     if ($value instanceof \DateTime) {
         $value = $value->format("d.m.Y");
     }
     parent::setValue($value);
     return $this;
 }
コード例 #15
0
ファイル: Typeahead.php プロジェクト: nextras/forms
 protected function attached($component)
 {
     parent::attached($component);
     $this->componentControlAttached($component);
     if ($component instanceof Nette\Application\IPresenter) {
         $this->control->{'data-typeahead-url'} = $this->link('autocomplete!', ['q' => '__QUERY_PLACEHOLDER__']);
     }
 }
コード例 #16
0
ファイル: Date.php プロジェクト: webchemistry/forms-controls
 /**
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->appendAttribute('class', ['js', 'date-input']);
     $control->data('format', $this->format);
     $control->data('settings', $this->settings);
     if ($this->value) {
         $control->value($this->value->format($this->format));
     }
     return $control;
 }
コード例 #17
0
ファイル: BaseDateTime.php プロジェクト: norbe/framework
	/**
	 * @param \DateTime
	 * @return BaseDateTime
	 */
	public function setValue($value = NULL)
	{
		try {
			if ($value instanceof \DateTime) {
				return parent::setValue($value->format(static::$format));
			} else {
				return parent::setValue($value);
			}
		} catch (\Exception $e) {
			return parent::setValue(NULL);
		}
	}
コード例 #18
0
 /**
  * @param \DateTime
  * @return BaseDateTime
  */
 public function setValue($value)
 {
     try {
         if ($value instanceof DateTime || $value instanceof \DibiDateTime) {
             parent::setValue($value->format($this->format));
         } elseif ($value != '') {
             $date = DateTime::from($value);
             parent::setValue($date->format($this->format));
         }
     } catch (\Exception $e) {
         return parent::setValue(NULL);
     }
 }
コード例 #19
0
ファイル: FileUpload.php プロジェクト: vsek/formExtension
 public function getValue()
 {
     $value = parent::getValue();
     if ($this->multiple) {
         $images = array();
         foreach (explode(',', $value) as $img) {
             if ($img != '') {
                 $images[] = $img;
             }
         }
         return $images;
     } else {
         return $value;
     }
 }
コード例 #20
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl($needLink = TRUE)
 {
     $control = parent::getControl();
     if (!$this->link) {
         $presenter = $this->lookup('Nette\\Application\\IPresenter', FALSE);
         if ($presenter || $needLink) {
             $url = $this->lookup('Nette\\Application\\IPresenter')->link('suggestion', array('path' => base64_encode($this->lookupPath('Nette\\Application\\IPresenter'))));
             $control->data('url', urldecode($url));
         }
     } else {
         $url = $this->link;
         $control->data('url', urldecode($url));
     }
     $control->appendAttribute('class', 'suggestion-input');
     $control->data('suggestion', $this->settings);
     return $control;
 }
コード例 #21
0
ファイル: IntegerPicker.php プロジェクト: vbuilder/framework
 public function getControl()
 {
     $container = Nette\Utils\Html::el('span');
     $control = parent::getControl();
     $control->class[] = 'form-control integerPicker';
     /*$template = $this->getForm()->getPresenter()->createTemplate();
     		$template->setFile(__DIR__.'/Templates/control.latte');
     		$template->input = $control; */
     $context = $this->getForm()->getPresenter()->getContext();
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/Templates/control.latte');
     $latte = $context->getService('nette.latte');
     $template->registerFilter($latte);
     vBuilder\Latte\Macros\SystemMacros::install($latte->compiler);
     $template->context = $context;
     $template->input = $control;
     $template->_control = $this->getForm()->lookup('Nette\\Application\\UI\\Control', true);
     $container->setHtml($template);
     return $container;
 }
コード例 #22
0
ファイル: Container.php プロジェクト: rostenkowski/nette
 /**
  * Adds single-line text input control used for sensitive input such as passwords.
  * @param  string  control name
  * @param  string  label
  * @param  int  width of the control (deprecated)
  * @param  int  maximum number of characters the user may enter
  * @return Nette\Forms\Controls\TextInput
  */
 public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NULL)
 {
     $control = new Controls\TextInput($label, $maxLength);
     if ($cols) {
         trigger_error(__METHOD__ . '() third parameter $cols is deprecated, use setAttribute("size", ...).', E_USER_DEPRECATED);
         $control->setAttribute('size', $cols);
     }
     return $this[$name] = $control->setType('password');
 }
コード例 #23
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $this->createRule();
     if ($this->settings) {
         $control->data('mask-input', $this->settings);
     }
     return $control;
 }
コード例 #24
0
 /**
  * @return TextInput
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control = $this->addAntispamScript($control);
     return $control;
 }
コード例 #25
0
ファイル: SuggestInput.php プロジェクト: soundake/pd
 /**
  * Returns the control's HTML
  *
  * Adds the javascript code for initializing the functionality
  * 
  * @return Html
  * @throws InvalidStateException If no suggest link is provided
  */
 public function getControl()
 {
     $control = parent::getControl();
     if ($this->suggestLink === NULL) {
         throw new InvalidStateException('SuggustInput::$suggestLink cannot be NULL');
     }
     $control->data('nette-suggestLink', $this->suggestLink);
     $options = $this->getJsOptions();
     if (!isset($options['lang'])) {
         $options['lang'] = self::$defaultUiLanguage;
     }
     $options = substr(PHP_VERSION_ID >= 50400 ? json_encode($options, JSON_UNESCAPED_UNICODE) : json_encode($options), 1, -1);
     $options = preg_replace('#"([a-z0-9_]+)":#i', '$1:', $options);
     $options = preg_replace('#(?<!\\\\)"(?!:[^a-z])([^\\\\\',]*)"#i', "'\$1'", $options);
     $control->data('nette-suggestInput-options', '{' . $options . '}');
     $control->class[] = 'suggestInput';
     return $control;
 }
コード例 #26
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->value = $this->value;
     return $control;
 }
コード例 #27
0
ファイル: TbDatePicker.php プロジェクト: cujan/vcelyweb
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->readonly = TRUE;
     return $control;
 }
コード例 #28
0
ファイル: TagsInput.php プロジェクト: svobodni/web
 /**
  * Adds a validation rule.
  * @param  mixed      rule type
  * @param  string     message to display for invalid data
  * @param  mixed      optional rule arguments
  * @return FormControl  provides a fluent interface
  */
 public function addRule($operation, $message = NULL, $arg = NULL)
 {
     switch ($operation) {
         case Form::EQUAL:
             if (!is_array($arg)) {
                 throw new \Nette\InvalidArgumentException(__METHOD__ . '(' . $operation . ') must be compared to array.');
             }
     }
     return parent::addRule($operation, $message, $arg);
 }
コード例 #29
0
 /**
  * Adds single-line text input control used for sensitive input such as passwords.
  * @param  string  control name
  * @param  string  label
  * @param  int  width of the control (deprecated)
  * @param  int  maximum number of characters the user may enter
  * @return Nette\Forms\Controls\TextInput
  */
 public function addPassword($name, $label = NULL, $cols = NULL, $maxLength = NULL)
 {
     $control = new Controls\TextInput($label, $maxLength);
     $control->setAttribute('size', $cols);
     return $this[$name] = $control->setType('password');
 }
コード例 #30
0
 /**
  * @inheritdoc
  */
 public function setDefaultValue($value)
 {
     if (!$value instanceof \DateTime) {
         $type = gettype($value);
         throw new InvalidArgumentException(sprintf("As default value, %s object must be given, '%s' given instead.", \DateTime::class, $type === 'object' ? get_class($value) : $type));
     }
     return parent::setDefaultValue($value);
 }