本文整理汇总了PHP中Nette\Forms\Container类的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addToFormContainer
/**
* 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());
}
}
示例2: addToFormContainer
/**
* 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());
}
}
示例3: setEntityToContainer
/**
* 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);
}
}
示例4: addToFormContainer
/**
* 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);
}
}
示例5: entityToForm
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;
}
示例6: generateForm
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);
}
示例7: addToFormContainer
/**
* 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());
}
}
示例8: generateForm
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);
}
示例9: setContainerDefaults
/**
* @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);
}
}
示例10: createImageUpload
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');
}
}
示例11: addControl
/**
* @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);
}
示例12: 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;
});
}
示例13: 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);
});
}
示例14: 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);
});
}
示例15: 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;
}