本文整理汇总了PHP中Nette\Forms\Container::extensionMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::extensionMethod方法的具体用法?PHP Container::extensionMethod怎么用?PHP Container::extensionMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Container
的用法示例。
在下文中一共展示了Container::extensionMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* 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;
});
}
示例2: register
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);
});
}
示例3: createForm
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;
}
示例4: bind
/**
* @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);
});
}
示例5: register
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;
});
}
示例6: register
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;
});
}
示例7: register
/**
* 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);
});
}
示例8: __construct
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);
});
}
示例9: register
public static function register()
{
Container::extensionMethod('addGMap', function (Container $form, $name, $label = null) {
$component = new NetteGMapPicker($label);
$form->addComponent($component, $name);
return $component;
});
}
示例10: startup
protected function startup()
{
parent::startup();
Container::extensionMethod('addDatePicker', function (Container $container, $name, $label = NULL) {
return $container[$name] = new DatePicker($label);
});
$this->setErrorPresenter();
}
示例11: register
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);
});
}
示例12: registerControls
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);
});
}
示例13: register
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;
});
}
示例14: register
/**
* 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;
});
}
示例15: register
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.';
}