/** * 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; }); }
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; }
/** * @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); }); }
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; }); }
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); }); }
public static function register() { Container::extensionMethod('addGMap', function (Container $form, $name, $label = null) { $component = new NetteGMapPicker($label); $form->addComponent($component, $name); return $component; }); }
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 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); }); }
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; }); }
/** * 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; }); }
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; }); \Nette\Forms\Rules::$defaultMessages[__CLASS__ . '::validateDateInputRange'] = \Nette\Forms\Rules::$defaultMessages[\Nette\Forms\Form::RANGE]; \Nette\Forms\Rules::$defaultMessages[__CLASS__ . '::validateDateInputValid'] = 'Please enter a valid date.'; }
public static function bind($config) { // Bind to form container to cache for DatePickerInput Container::extensionMethod('addDatePickerInput', function ($container, $name, $label = NULL) use($config) { return $container[$name] = new DatePickerInput($label, $config); }); // Bind to form container to cache form DatePickerRange Container::extensionMethod('addDatePickerRange', function ($container, $name, $label = NULL) use($config) { return $container[$name] = new DatePickerRange($label, $config); }); }
/** * Registers this control * * @param string $format format * @return self */ public static function register($format = NULL) { Container::extensionMethod('addTbDatePicker', function ($container, $name, $label = NULL, $maxLength = NULL) use($format) { $picker = $container[$name] = new TbDatePicker($label, $maxLength); if ($format !== NULL) { $picker->setFormat($format); } return $picker; }); parent::setValidationMessages(); }
public function __construct(Session $session) { AntispamControl::register(); Container::extensionMethod('addDateInput', function (Container $container, $name, $label = NULL) { return $container[$name] = new DateInput($label); }); Container::extensionMethod('addTextCaptcha', function (Container $container, $name, $label = NULL) use($session) { $textCaptcha = new TextCaptcha($label); $textCaptcha->setSession($session); return $container[$name] = $textCaptcha; }); }
/** * Registers 'add*Buttons' & 'add*Button' methods to form * * @param Binder $binder * @param AbstractPaymentService $service */ public static function registerAddPaymentButtons(Binder $binder, AbstractPaymentService $service) { $class = new ReflectionClass($service); $method = lcfirst(str_replace('Service', '', $class->getShortName())); FormContainer::extensionMethod('add' . $method . 'Buttons', function ($container, $callbacks) use($binder, $service) { $binder->bindPaymentButtons($service, $container, $callbacks); }); FormContainer::extensionMethod('add' . $method . 'Button', function ($container, $channel, $callback = NULL) use($binder, $service) { $channels = $service->getChannels(); if (!isset($channels[$channel])) { throw new InvalidArgumentException("Channel '{$channel}' is not allowed."); } return $binder->bindPaymentButton($channels[$channel], $container, $callback = []); }); }
/** * @static * @param $systemContainer * @param array $configuration */ public static function register(\Nette\DI\Container $systemContainer, $configuration = []) { $class = __CLASS__; \Nette\Forms\Container::extensionMethod("addFileUpload", function (\Nette\Forms\Container $container, $name, $maxFiles = NULL, $maxFileSize = NULL) use($class, $systemContainer, $configuration) { $maxFiles = is_null($maxFiles) ? $configuration["maxFiles"] : $maxFiles; $maxFileSize = is_null($maxFileSize) ? $configuration["maxFileSize"] : $maxFileSize; /** @var FileUploadControl $component */ $component = new $class($name, $maxFiles, $maxFileSize); $component->setContainer($systemContainer); $component->setUploadModel($configuration["uploadModel"]); $component->setFileFilter($configuration["fileFilter"]); $component->setUIMode($configuration["uiMode"]); $container->addComponent($component, $name); return $component; }); }
public static function registerControls() { Container::extensionMethod('addOptionList', function (Container $container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new Controls\OptionList($label, $items); }); Container::extensionMethod('addMultiOptionList', function (Container $container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new Controls\MultiOptionList($label, $items); }); Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new Controls\DatePicker($label); }); Container::extensionMethod('addDateTimePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new Controls\DateTimePicker($label); }); Container::extensionMethod('addTypeahead', function (Container $container, $name, $label = NULL, $callback = NULL) { return $container[$name] = new Controls\Typeahead($label, $callback); }); }
public function registerMethods() { Container::extensionMethod('autoFill', function (Container $container, $values, $erase = false) { if ($values instanceof \Traversable) { $values = iterator_to_array($values); } foreach ($container->getComponents() as $name => $control) { if ($control instanceof IControl) { if (is_array($values)) { if (array_key_exists($name, $values)) { $control->setValue($values[$name]); } elseif ($erase) { $control->setValue(null); } } else { if (isset($values->{$name})) { $control->setValue($values->{$name}); } elseif ($erase) { $control->setValue(null); } } } elseif ($control instanceof Container) { if (is_array($values)) { if (array_key_exists($name, $values)) { $control->autoFill($values[$name], $erase); } elseif ($erase) { $control->autoFill(array(), $erase); } } else { if (isset($values->{$name})) { $control->autoFill($values->{$name}); } elseif ($erase) { $control->autoFill(null); } } } } return $this; }); }
/** * @param ProviderFactory $providerFactory */ public static function bind(ProviderFactory $providerFactory) { Container::extensionMethod('addCaptcha', function ($container, $name = 'captcha') use($providerFactory) { return $container[$name] = new CaptchaContainer($providerFactory->create()); }); }
/** * Adds addDependentSelectBox() method to \Nette\Forms\Form */ public static function register() { Container::extensionMethod('addDependentSelectBox', array('NasExt\\Forms\\Controls\\DependentSelectBox', 'addDependentSelectBox')); }
public static function register() { Container::extensionMethod('addCheckboxTree', function (Container $_this, $name, $label, array $items = NULL) { return $_this[$name] = new CheckboxTree($label, $items); }); }
/** * @param array $config */ public static function bind($config) { Container::extensionMethod('addTypeahead', function ($container, $name, $label = NULL, $display = NULL, $remote = NULL) use($config) { return $container[$name] = new TypeaheadInput($label, $config, $display, $remote); }); }
public static function register($method = 'addSelectize', $config) { Nette\Forms\Container::extensionMethod($method, function (Nette\Forms\Container $container, $name, $label, $entity = null, array $options = null) use($config) { $container[$name] = new Selectize($label, $entity, is_array($options) ? array_replace($config, $options) : $config); return $container[$name]; }); }
/** * @param string $name */ public static function register($name = 'addCheckboxList') { Nette\Forms\Container::extensionMethod($name, function (Nette\Forms\Container $container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new static($label, $items); }); }
/** * Registers this control * * @return self */ public static function register() { Container::extensionMethod('addImageSelectBox', function ($container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new ImageSelectBox($label, $items); }); }
<?php require __DIR__ . '/../vendor/autoload.php'; use Nette\Forms\Container; use Nextras\Forms\Controls; Container::extensionMethod('addOptionList', function (Container $container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new Controls\OptionList($label, $items); }); Container::extensionMethod('addMultiOptionList', function (Container $container, $name, $label = NULL, array $items = NULL) { return $container[$name] = new Controls\MultiOptionList($label, $items); }); Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new Controls\DatePicker($label); }); Container::extensionMethod('addDateTimePicker', function (Container $container, $name, $label = NULL) { return $container[$name] = new Controls\DateTimePicker($label); }); Container::extensionMethod('addTypeahead', function (Container $container, $name, $label = NULL, $callback = NULL) { return $container[$name] = new Controls\Typeahead($label, $callback); }); $configurator = new Nette\Configurator(); //$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP $configurator->enableDebugger(__DIR__ . '/../log'); $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader()->addDirectory(__DIR__)->register(); $configurator->addConfig(__DIR__ . '/config/config.neon'); $configurator->addConfig(__DIR__ . '/config/config.local.neon'); $container = $configurator->createContainer(); return $container;