本文整理汇总了PHP中Nette\Forms\Container::getForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getForm方法的具体用法?PHP Container::getForm怎么用?PHP Container::getForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Container
的用法示例。
在下文中一共展示了Container::getForm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Nette\Forms\Container $container, EntityFormMapper $mapper, ControlFactory $controlFactory = NULL, EntityManager $em = NULL)
{
$this->container = $container;
$this->mapper = $mapper;
$this->em = $em ?: $mapper->getEntityManager();
$this->controlFactory = $controlFactory ?: new ControlFactory();
/** @var Nette\Application\UI\Form|Kdyby\DoctrineForms\EntityForm $form */
if (method_exists($form = $container->getForm(FALSE), 'injectEntityMapper')) {
$form->injectEntityMapper($this->mapper);
}
}
示例2: findControl
/**
* @param Container $container
* @param ConstraintViolationInterface $violation
* @return Nette\Forms\IControl|Nette\Forms\Controls\BaseControl|UI\Form
*/
private function findControl(Container $container, ConstraintViolationInterface $violation)
{
if (!($m = Nette\Utils\Strings::split('.' . $violation->getPropertyPath(), '~([\\.\\[])~'))) {
return $container->getForm();
// apply the error to form
}
$control = $container;
while (($type = array_shift($m)) !== NULL && $control) {
if (empty($type)) {
continue;
}
$step = array_shift($m);
if ($type === '[') {
$step = substr($step, 0, -1);
}
$control = $control->getComponent($step, FALSE);
}
return $control instanceof Nette\Forms\IControl ? $control : $container->getForm();
}
示例3: getControlGroup
/**
* @param Forms\Container $container
* @param IGroupConfig $groupConfig
* @return Forms\ControlGroup
*/
private static function getControlGroup(Forms\Container $container, IGroupConfig $groupConfig)
{
$form = $container->getForm();
$group = $form->getGroup($groupConfig->getLabel());
if ($group === NULL) {
// Create group
$group = $form->addGroup($groupConfig->getLabel(), FALSE);
foreach ($groupConfig->getOptions() as $key => $value) {
$group->setOption($key, $value);
}
}
return $group;
}
示例4: validate
protected function validate()
{
$this->mapper->runValidation(function (ValidatorInterface $validatorInterface) {
return $validatorInterface->validatePropertyValue($this->wrappedEntity->getEntity(), $this->component->name, $this->collection);
}, $this->component instanceof BaseControl ? $this->component : $this->component->getForm());
}
示例5: findControl
/**
* @param Container $container
* @param ConstraintViolationInterface $violation
* @return Nette\Forms\IControl|Nette\Forms\Controls\BaseControl|Nette\Application\UI\Form
*/
protected function findControl(Container $container, ConstraintViolationInterface $violation)
{
// propertyPath eg. addresses[1].street
$path = preg_split('/\\]\\.|\\.|\\[|\\]/', $violation->getPropertyPath(), -1, PREG_SPLIT_NO_EMPTY);
$control = $container;
while (($step = array_shift($path)) !== NULL && $control) {
$control = $control->getComponent($step, FALSE);
}
return $control instanceof Nette\Forms\IControl || $control instanceof IContainer ? $control : $container->getForm();
}