/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $effortOptions = $this->container->get('form_helper')->getProjectEffortMethodOptions(); $project = null; $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($builder) { $form = $event->getForm(); $data = $event->getData(); if ($data instanceof Entity\Project) { $project = $data; } }); $builder->add('name', Type\TextType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.name')))->add('description', Type\TextareaType::class, array('required' => false, 'label' => $this->translator->trans('backend.project.description')))->add('startDate', Type\DateType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.start_date'), 'placeholder' => array('year' => $this->translator->trans('backend.global.year'), 'month' => $this->translator->trans('backend.global.month'), 'day' => $this->translator->trans('backend.global.day')), 'format' => $project != null ? $project->getSettings()->getPHPDateFormat() : 'y-M-d', 'years' => Util::getYearstoForm(3)))->add('estimatedDate', Type\DateType::class, array('required' => false, 'label' => $this->translator->trans('backend.project.estimated_date'), 'placeholder' => array('year' => $this->translator->trans('backend.global.year'), 'month' => $this->translator->trans('backend.global.month'), 'day' => $this->translator->trans('backend.global.day')), 'format' => $project != null ? $project->getSettings()->getPHPDateFormat() : 'y-M-d', 'years' => Util::getYearstoForm(4)))->add('effortEstimationMethod', Type\ChoiceType::class, array('required' => true, 'label' => $this->translator->trans('backend.project.effort_method'), 'choices' => $effortOptions)); }