本文整理匯總了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();
}