/** * Add dynamic container to the form. * * @param type $name * @param type $factory * @param type $createDefault * @param bool $forceDefault * @return type */ public function addDynamic($form, $name, $factory, $createDefault = 0, $forceDefault = FALSE) { \Kdyby\Replicator\Container::register(); $control = new \Kdyby\Replicator\Container($factory, $createDefault, $forceDefault); $control->containerClass = 'Venne\\Forms\\Container'; return $form[$name] = $control; }
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 EntityReader $reader * @param User $user * @param DataFetcher $fetcher */ public function __construct(EntityReader $reader, User $user, DataFetcher $fetcher) { $this->reader = $reader; $this->user = $user; $this->fetcher = $fetcher; \Kdyby\Replicator\Container::register(); \Vodacek\Forms\Controls\DateInput::register(); }
/** * @param $form * @param $name * @param $containerFactory * @param null $entityFactory * @return \DoctrineModule\Forms\Containers\CollectionContainer */ public function addMany($form, $name, $containerFactory, $entityFactory = NULL) { Container::register(); $collection = $form->getMapper()->getCollection($form->getData(), $name); $form[$name] = $control = new \DoctrineModule\Forms\Containers\CollectionContainer($collection, $containerFactory); if ($entityFactory) { $control->setEntityFactory($entityFactory); } $control->containerClass = 'DoctrineModule\\Forms\\Containers\\EntityContainer'; return $control; }
/** * @return \Nette\Application\UI\Form */ public function create() { \Kdyby\Replicator\Container::register(); $form = $this->formFactory->create(); $userTypes = array(); foreach ($this->securityManager->getUserTypes() as $name => $val) { $userTypes[$name] = $val->getName(); } $form->addCheckbox('enabled', 'Enabled'); $form->addCheckbox('invitation', 'Only as invitation'); $form->addText('name', 'Name'); $form->addHidden('key'); $form->addSelect('userType', 'Type', $userTypes); $form->addSelect('mode', 'Mode', Registration::getModes()); $form->addSelect('loginProviderMode', 'Login provider mode', Registration::getLoginProviderModes()); $form->addMultiSelect('roles', 'Roles')->setOption(IComponentMapper::ITEMS_TITLE, 'name'); return $form; }
private function registerReplicator() { if (!ObjectMixin::getExtensionMethod(SubmitButton::class, 'addCreateOnClick')) { Replicator::register(); } }
/** * Magical component factory * * @param string $name * @return \Nette\Forms\Container */ protected function createComponent($name) { $container = parent::createComponent($name); return $this->created[$container->name] = $container; }
/** * @param \Nette\Forms\Container|\Kdyby\Doctrine\Forms\EntityContainer $container * @param bool $cleanUpGroups */ public function remove(Nette\Forms\Container $container, $cleanUpGroups = FALSE) { if (!$container instanceof \DoctrineModule\Forms\Containers\EntityContainer) { throw new \Nette\InvalidArgumentException('Given container is not instance of DoctrineModule\\Forms\\Containers\\EntityContainer, instance of ' . get_class($container) . ' given.'); } $entity = $container->getData(); parent::remove($container, $cleanUpGroups); $this->getMapper()->remove($entity); }
case "www.peknyden.cz": $environment = "production"; break; default: $environment = "development"; break; } $configurator->addConfig(__DIR__ . '/config/config.neon', $environment); $configurator->onCompile[] = function ($configurator, $compiler) { $compiler->addExtension('dibi', new DibiNette21Extension()); }; $detect = new Mobile_Detect(); //$configurator->addParameters(array("isMobile" => $detect->isMobile())); $configurator->addParameters(array("isMobile" => false)); /* @var $container \SystemContainer */ $container = $configurator->createContainer(); dibi::connect($container->parameters['database']); // addDynamic / Replicator \Kdyby\Replicator\Container::register(); // DatePicker.php registration Container::extensionMethod('addDatePicker', function (\Nette\Forms\Container $container, $name, $label = NULL) { return $container[$name] = new \JanTvrdik\Components\DatePicker($label); }); // TimePicker.php registration Container::extensionMethod('addTimePicker', function (\Nette\Forms\Container $container, $name, $label = NULL) { return $container[$name] = new \soundake\Components\TimePicker($label); }); // SuggestInput registration Nette\Forms\Form::extensionMethod('Nette\\Forms\\Form::addSuggestInput', 'Nette\\Addons\\SuggestInput::addSuggestInput'); define('BASEPATH', $container->httpRequest->getUrl()->basePath); return $container;