本文整理汇总了PHP中Symfony\Component\Form\FormEvent::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP FormEvent::getName方法的具体用法?PHP FormEvent::getName怎么用?PHP FormEvent::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormEvent
的用法示例。
在下文中一共展示了FormEvent::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setData
public function setData($data)
{
if ($this->event->getName() == FormEvents::PRE_SUBMIT) {
$this->event->setData($data);
} else {
trigger_error(__CLASS__ . "::" . __FUNCTION__ . " can only be called in BoltFormsEvents::PRE_SUBMIT", E_USER_ERROR);
}
}
示例2: setData
public function setData($data)
{
if ($this->event->getName() === FormEvents::PRE_SUBMIT) {
$this->event->setData($data);
} else {
throw new \RuntimeException(__CLASS__ . '::' . __FUNCTION__ . ' can only be called in BoltFormsEvents::PRE_SUBMIT');
}
}
示例3: preSubmitData
public function preSubmitData(FormEvent $event)
{
$data = $event->getData();
if (!$data) {
$data = $event->getForm()->getParent()->getData();
}
$form = $event->getForm();
$targetEntity = null;
if (isset($data['target_entity'])) {
$targetEntity = $data['target_entity'];
}
$relationType = $this->config->getId()->getFieldType();
if ($relationType == 'manyToOne') {
//target_field
$targetField = null;
if (isset($data['target_field'])) {
$targetField = $data['target_field'];
}
$form->add($this->formFactory->createNamed('target_field', new TargetFieldType($this->configProvider, $targetEntity), $targetField));
} else {
//target_grid
$targetGrid = null;
if (isset($data['target_grid'])) {
$targetGrid = $data['target_grid'];
}
$form->add($this->formFactory->createNamed('target_grid', new TargetFieldType($this->configProvider, $targetEntity), $targetGrid, ['multiple' => true, 'label' => 'Related entity data fields']));
//target_title
$targetTitle = null;
if (isset($data['target_title'])) {
$targetTitle = $data['target_title'];
}
$form->add($this->formFactory->createNamed('target_title', new TargetFieldType($this->configProvider, $targetEntity), $targetTitle, ['multiple' => true, 'label' => 'Related entity info title']));
//target_detailed
$targetDetailed = null;
if (isset($data['target_detailed'])) {
$targetDetailed = $data['target_detailed'];
}
$form->add($this->formFactory->createNamed('target_detailed', new TargetFieldType($this->configProvider, $targetEntity), $targetDetailed, ['multiple' => true, 'label' => 'Related entity detailed']));
}
if ($event->getName() == FormEvents::PRE_SUBMIT) {
$event->getForm()->getParent()->setData(array_merge($event->getForm()->getParent()->getData(), $data));
}
}
示例4: preSubmitData
public function preSubmitData(FormEvent $event)
{
$form = $event->getForm();
$data = $event->getData();
if (!$data) {
$data = $form->getParent()->getData();
}
if ($this->config->get('owner') === ExtendScope::OWNER_CUSTOM) {
$targetEntity = $this->getArrayValue($data, 'target_entity');
$relationType = $this->config->getId()->getFieldType();
if ($relationType == 'manyToOne') {
$this->addTargetField($form, 'target_field', $targetEntity, $this->getArrayValue($data, 'target_field'));
} else {
$this->addTargetField($form, 'target_grid', $targetEntity, $this->getArrayValue($data, 'target_grid'), 'Related entity data fields', true);
$this->addTargetField($form, 'target_title', $targetEntity, $this->getArrayValue($data, 'target_title'), 'Related entity info title', true);
$this->addTargetField($form, 'target_detailed', $targetEntity, $this->getArrayValue($data, 'target_detailed'), 'Related entity detailed', true);
}
}
if ($event->getName() == FormEvents::PRE_SUBMIT) {
$form->getParent()->setData(array_merge($form->getParent()->getData(), $data));
}
}