本文整理汇总了PHP中Symfony\Component\Form\FormEvent::stopPropagation方法的典型用法代码示例。如果您正苦于以下问题:PHP FormEvent::stopPropagation方法的具体用法?PHP FormEvent::stopPropagation怎么用?PHP FormEvent::stopPropagation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormEvent
的用法示例。
在下文中一共展示了FormEvent::stopPropagation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBind
/**
* @param \Symfony\Component\Form\FormEvent $event
*/
public function onBind(FormEvent $event)
{
$collection = $event->getForm()->getData();
$data = $event->getData();
// looks like there is no way to remove other listeners
$event->stopPropagation();
if (!$collection) {
$collection = $data;
} elseif (count($data) === 0) {
$this->modelManager->collectionClear($collection);
} else {
// merge $data into $collection
foreach ($collection as $entity) {
if (!$this->modelManager->collectionHasElement($data, $entity)) {
$this->modelManager->collectionRemoveElement($collection, $entity);
} else {
$this->modelManager->collectionRemoveElement($data, $entity);
}
}
foreach ($data as $entity) {
$this->modelManager->collectionAddElement($collection, $entity);
}
}
$event->setData($collection);
}
示例2: onPostSubmit
/**
* @param FormEvent $event
*/
public function onPostSubmit(FormEvent $event)
{
$form = $event->getForm()->get('_xml_http_request');
if ($form->getData() === 'true') {
$form->addError(new FormError('The validation has been disabled.'));
$event->stopPropagation();
}
}
示例3: postSubmit
/**
* @param FormEvent $event
*/
public function postSubmit(FormEvent $event)
{
$event->stopPropagation();
}