public function __invoke(FormEvent $event) { /* @var \Jobs\Form\Job $container */ $container = $event->getForm(); $container->setForm('invoice', ['priority' => -10, 'label' => 'Invoice Address', 'entity' => false, 'property' => false, 'forms' => ['invoiceAddress' => ['label' => 'Invoice Address', 'type' => 'Orders/JobInvoiceAddress', 'property' => true, 'options' => ['enable_descriptions' => true, 'description' => 'Please leave your contact completely . We need this data for business correspondence and coordination of questions about the job posting . These data are of course not be published.']]]]); $previewSpec = $container->getForm('preview', false); $previewSpec['priority'] = -20; $container->setForm('preview', $previewSpec); }
public function __invoke(FormEvent $event) { $invoiceAddress = $event->getForm()->getForm('invoice.invoiceAddress')->getObject(); foreach (['name', 'company', 'street', 'city', 'vatIdNumber'] as $field) { $value = $invoiceAddress->{"get{$field}"}(); if (empty($value)) { return 'Please fill in and check your invoice address.'; } } }
public function __invoke(FormEvent $event) { if ('job' != $event->getParam('param_name') || $event->getForm()->getObject()) { return; } $jobId = $event->getParam('param_value'); $entity = $this->repository->findByJobId($jobId); if ($entity) { $invoiceAddress = $entity->getInvoiceAddress(); } else { $callback = $this->createEntityCallback; $invoiceAddress = $callback(); $entity = $this->repository->create(['jobId' => $jobId, 'invoiceAddress' => $invoiceAddress], true); /* If form is not instantiated until rendering, the PersistenceListener has already run * at this time. So we need to manually store the entity to be sure it is persisted. * */ $this->repository->store($entity); } $form = $event->getForm(); $form->bind($invoiceAddress); }
public function __invoke(FormEvent $event) { $job = $event->getParam('job'); if ($job->isDraft()) { return; } /* @var \Orders\Form\InvoiceAddress $invoiceAddress */ $invoiceAddress = $event->getForm()->getForm('invoice.invoiceAddress'); $invoiceAddress->setDisplayMode(SummaryFormInterface::DISPLAY_SUMMARY); foreach ($invoiceAddress->getBaseFieldset() as $element) { $element->setAttribute('disabled', true); } }