/** * Adds text field to filter form * @param Nette\Forms\Container $container */ public function addToFormContainer($container) { $container->addText($this->key, $this->name); if ($this->getPlaceholder()) { $container[$this->key]->setAttribute('placeholder', $this->getPlaceholder()); } }
/** * Adds select box to filter form * @param Nette\Forms\Container $container */ public function addToFormContainer($container) { $container->addText($this->key, $this->name)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true'); if ($this->getPlaceholder()) { $container[$this->key]->setAttribute('placeholder', $this->getPlaceholder()); } }
/** * Map Entity to form * * @param object $entity * @param Container $container */ public function setEntityToContainer($entity, Container $container) { // go throw all components and try find values for it /** @var BaseControl $component */ foreach ($container->getComponents() as $component) { $this->mapValueToComponent($entity, $component); } }
/** * Adds select box to filter form * @param Nette\Forms\Container $container */ public function addToFormContainer($container) { $form = $container->lookup('Nette\\Application\\UI\\Form'); $translator = $form->getTranslator(); $select = $container->addSelect($this->key, $translator->translate($this->name), $this->options); if (!$this->translateOptions) { $select->setTranslator(NULL); } }
public function entityToForm($entity, Nette\Forms\Container $form) { foreach ($form->getComponents() as $name => $control) { if (isset($entity->{$name})) { $form[$name]->setValue($entity->{$name}); } } return $form; }
public function addIdentifiers() { $components = []; foreach ($this->metadata->getIdentifierFieldNames() as $name) { if (!isset($this->containerPrototype[$name])) { $components[$name] = $this->containerPrototype->addHidden($name); } } return $components; }
public function generateForm(Items\Base $item, Nette\Forms\Container &$formContainer, $name, $parentName, $togglingObject, array $userOptions = []) { $input = $formContainer->addTextArea($name, $name); $input->setOption('id', $parentName . '__' . $name); $input->setValue($item->getContent()); if (!is_null($togglingObject)) { $togglingObject->toggle($input->getOption('id')); } $item->applyUserOptions($input, $userOptions); }
/** * Adds select box to filter form * @param Nette\Forms\Container $container */ public function addToFormContainer(Nette\Forms\Container $container) { $container->addText($this->key, $this->name)->setAttribute('data-provide', 'datepicker')->setAttribute('data-date-orientation', 'bottom')->setAttribute('data-date-format', $this->getJsFormat())->setAttribute('data-date-today-highlight', 'true')->setAttribute('data-date-autoclose', 'true'); $this->addAttributes($container[$this->key]); if ($this->grid->hasAutoSubmit()) { $container[$this->key]->setAttribute('data-autosubmit-change', TRUE); } if ($this->getPlaceholder()) { $container[$this->key]->setAttribute('placeholder', $this->getPlaceholder()); } }
public function generateForm(Items\Base $item, Nette\Forms\Container &$formContainer, $name, $parentName, $togglingObject, array $userOptions = []) { $input = $formContainer->addText($name, $name); $input->setOption('id', $parentName . '__' . $name); $input->setValue($item->getContent()); $input->setType('time'); $input->addCondition(UI\Form::FILLED)->addRule(UI\Form::PATTERN, __('Time must be in format HH:MM'), '([0-9]{2}[-: ]{1}[0-9]{2})'); if (!is_null($togglingObject)) { $togglingObject->toggle($input->getOption('id')); } $item->applyUserOptions($input, $userOptions); }
/** * @param Nette\Forms\Container $parent * @param string $name * @param mixed $values */ protected function setContainerDefaults(Nette\Forms\Container $parent, $name, $values) { if ($values === NULL) { return; } $component = $parent->getComponent($name); $factory = $this->getContainerFactory($name); if ($values instanceof IFormEntity) { $factory->setDefaultByEntity($component, $values); } else { $factory->setDefaultByCollection($component, $values); } }
protected function createImageUpload(Nette\Forms\Container $container, $image) { $id = $this->lookupPath('Nette\\Application\\UI\\Presenter') . '-form'; if ($image !== NULL) { $container->addCheckbox('deleteImg', 'common.form.removeImage')->addCondition(Form::EQUAL, FALSE)->toggle($id . '-pic-customize'); } $container->addFileUpload('img', 'common.form.image')->setOption('id', $id . '-pic-image')->addCondition(Form::FILLED)->addRule(Form::IMAGE); // upload is filled => show img options $container['img']->addCondition(Form::FILLED)->toggle($id . '-pic-customize'); // has image and deleteImg is checked => show upload if ($image !== NULL) { $container['deleteImg']->addCondition(Form::EQUAL, TRUE)->toggle($id . '-pic-image'); } }
/** * @param Nette\Forms\Container $container * @param string $key * @param string $name * @param array $options * @return Nette\Forms\Controls\SelectBox */ protected function addControl(Nette\Forms\Container $container, $key, $name, $options) { /** * Set some translated texts */ $form = $container->lookup('Nette\\Application\\UI\\Form'); $t = [$form->getTranslator(), 'translate']; $this->addAttribute('title', $t('ublaboo_datagrid.multiselect_choose')); $this->addAttribute('data-i18n-selected', $t('ublaboo_datagrid.multiselect_selected')); /** * Add input to container */ $input = $container->addMultiSelect($key, $name, $options); return $this->addAttributes($input); }
/** * Registers this control * * @return DateTimePicker */ public static function register() { Container::extensionMethod('addDateTime', function ($container, $name, $label = NULL) { $picker = $container[$name] = new DateTimePicker($label); return $picker; }); }
/** * @param string $siteKey * @param string $name * @return void */ public static function bind($siteKey, $name = 'addReCaptcha') { // Bind to form container Container::extensionMethod($name, function ($container, $name, $label = NULL) use($siteKey) { return $container[$name] = new ReCaptchaField($siteKey, $label); }); }
protected function attached($obj) { parent::attached($obj); if ($obj instanceof Form) { $this->configure(); } }
public static function register($format = 'yyyy-mm-dd', $language = 'en', $method = 'addDatePicker') { $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; \Nette\Forms\Container::extensionMethod($method, function (\Nette\Forms\Container $container, $name, $label = NULL) use($class, $format, $language) { return $container[$name] = new $class($format, $language, $label); }); }
protected function createForm() { $form = new Form(); Container::extensionMethod('addLazyContainer', function ($container, $name, $factory) { return $container[$name] = new LazyContainer($factory); }); $base = $form->addContainer('base'); $base->addText('name', 'Název'); $type = $base->addSelect('type', 'Typ položky', $this->menuTypeOptionFactory->getOptionsBySection($this->sectionId)); $type->setDefaultValue(key($type->getItems())); $type->setAttribute('class', 'change-ajax-submit'); $base->addCheckbox('show', 'Zobrazit')->setDefaultValue(TRUE); $parent = $form->addContainer('parent'); $menu = $parent['id_menu'] = $this->menuFormItemFactory->create($this->sectionId); $menu->setPrompt('---'); $menu->caption = 'Rodičovská kategorie'; $form->addLazyContainer('content', function (LazyContainer $self) use($form, $type) { $values = $self->getFormValues(); $itemType = $values['base']['type']; $this->lazyItemMap->get($itemType)->setup($self, $this->sectionId); }); $form->addSubmit('save', 'Uložit'); $form->onValidate[] = $this->validateNonCircular; $form->onValidate[] = $this->validateAjax; $form->onValidate[] = $this->validateLazyItem; return $form; }
public static function register() { Kdyby\Replicator\Container::register(); Container::extensionMethod('addHasOne', function (Container $container, $name, $label = NULL, $column = NULL, array $items = NULL) { $control = $container[$name] = new HasOneControl($label, $column, $items); return $control; }); Container::extensionMethod('addHasMany', function (Container $container, $name, $column = NULL, array $items = NULL) { $control = $container[$name] = new HasManyControl($column, $items); $control->setCurrentGroup($container->form->getCurrentGroup()); return $control; }); // WYSIWYG Container::extensionMethod('addWysiwyg', function (Container $container, $name, $label = NULL, $rows = NULL, $cols = NULL) { $control = $container->addTextArea($name, $label, $cols, $rows); $control->getControlPrototype()->class('wysiwyg'); return $control; }); // E-mail Container::extensionMethod('addEmail', function (Container $container, $name, $label = NULL, $cols = NULL, $maxLength = NULL) { $control = $container->addText($name, $label, $cols, $maxLength); $control->setAttribute('type', 'email'); $control->addCondition(Form::FILLED)->addRule(Form::EMAIL); return $control; }); // URL Container::extensionMethod('addUrl', function (Container $container, $name, $label = NULL, $cols = NULL, $maxLength = NULL) { $control = $container->addText($name, $label, $cols, $maxLength); $control->setAttribute('type', 'url'); $control->addCondition(Form::FILLED)->addRule(Form::URL); return $control; }); // Color Container::extensionMethod('addColor', function (Container $container, $name, $label = NULL, $cols = NULL, $maxLength = NULL) { $control = $container->addText($name, $label, $cols, $maxLength); $control->setAttribute('type', 'color'); return $control; }); // Number Container::extensionMethod('addNumber', function (Container $container, $name, $label = NULL, $step = NULL, $min = NULL, $max = NULL, $cols = NULL, $maxLength = NULL) { $control = $container->addText($name, $label, $cols, $maxLength); $control->setAttribute('type', 'number'); $control->setAttribute('step', $step); $control->addCondition(Form::FILLED)->addRule(Form::NUMERIC); $range = []; if ($min !== NULL) { $control->setAttribute('min', $min); $range[0] = $min; } if ($max !== NULL) { $control->setAttribute('max', $max); $range[1] = $max; } if ($range != [NULL, NULL]) { $control->addCondition(Form::FILLED)->addRule(Form::RANGE, NULL, $range); } return $control; }); }
/** * @param \Nette\ComponentModel\IContainer */ protected function attached($presenter) { parent::attached($presenter); if (!$presenter instanceof Nette\Application\UI\Presenter) { return; } $this->loadHttpData(); }
public static function register() { Container::extensionMethod('addGMap', function (Container $form, $name, $label = null) { $component = new NetteGMapPicker($label); $form->addComponent($component, $name); return $component; }); }
/** * @param $name * @param $args * @return \Nette\Forms\Container|Container */ public function __call($name, $args) { if (substr($name, 0, 3) !== 'add') { return parent::__call($name, $args); } $args = array_merge(array(lcfirst(substr($name, 3))), $args); return call_user_func_array(array($this, 'add'), $args); }
public static function register() { \Nette\Forms\Container::extensionMethod('addDate', function (\Nette\Forms\Container $form, $name, $label = null, $type = 'datetime') { $component = new NetteDateTime($label, $type); $form->addComponent($component, $name); return $component; }); }
/** * Adds addTextOutput() method to Nette\Forms\Container */ public static function register() { Container::extensionMethod('addTextOutput', function (Container $_this, $value, $label = NULL) { $number = TextOutput::$counter; TextOutput::$counter++; return $_this["textOutput_" . $number] = new TextOutput($value, $label); }); }
public function __construct(ReservationManager $rm, CarsModel $cm) { $this->reservationManager = $rm; $this->carsModel = $cm; Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new DatePicker($label); }); }
protected function startup() { parent::startup(); Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new DatePicker($label); }); $this->setErrorPresenter(); }
public static function register(Translator $translator) { Nette\Forms\Container::extensionMethod('enableLocalized', function (\Nette\Application\UI\Form $form) use($translator) { $form->setTranslator($translator); }); Nette\Forms\Container::extensionMethod('translate', function (\Nette\Application\UI\Form $form, $message, $count = null, $parameters = array()) use($translator) { return $translator->translate($message, $count, $parameters); }); }
public static function register() { $class = __CLASS__; \Nette\Forms\Container::extensionMethod('addDate', function (\Nette\Forms\Container $form, $name, $label = null, $type = 'datetime-local') use($class) { $component = new $class($label, $type); $form->addComponent($component, $name); return $component; }); }
public static function registerControls() { Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new DatePicker($label); }); Container::extensionMethod('addDateTimePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new DateTimePicker($label); }); }
/** * @param SeznamCaptcha $provider */ public function __construct(SeznamCaptcha $provider) { parent::__construct(); $this->provider = $provider; $this->validator = new CaptchaValidator($provider); $this['image'] = new CaptchaImage('Captcha', $provider); $this['code'] = new CaptchaInput('Code'); $this['hash'] = new CaptchaHash($provider); }
/** * Registrace AntiSpamu. * @static * @param $systemContainer */ public static function register($systemContainer) { $class = __CLASS__; \Nette\Forms\Container::extensionMethod("addAntiSpam", function (\Nette\Forms\Container $container, $name, $blockingTime = 0, $minimumReadTime = 60) use($class, $systemContainer) { $component = new $class($name, $blockingTime, $minimumReadTime); $component->setContainer($systemContainer); $container->addComponent($component, $name); return $component; }); }