public function buildForm(FormBuilderInterface $builder, array $options) { /** * @var $attributes ProductAttribute[] */ $data = $options['data']; $attributes = $data[C::FORM_ATTRIBUTE_LIST]; foreach ($attributes as $attribute) { $formId = AbstractAttribute::FORM_PREFIX . $attribute->getId(); switch ($attribute->getType()) { case ProductAttribute::ATTRIBUTE_TYPE_NUMBER: $builder->add($formId, TextType::class, ['label' => $attribute->getName(), 'required' => false, 'attr' => ['class' => 'generated_number_type']]); break; case ProductAttribute::ATTRIBUTE_TYPE_STRING: $builder->add($formId, TextType::class, ['label' => $attribute->getName(), 'required' => false, 'attr' => ['class' => 'generated_string_type']]); break; break; case ProductAttribute::ATTRIBUTE_TYPE_BOOL: $builder->add($formId, CheckboxType::class, ['label' => $attribute->getName(), 'required' => false]); break; case ProductAttribute::ATTRIBUTE_TYPE_REFERENCE: $reference = $attribute->getReference(); $builder->add($formId, ChoiceType::class, ['label' => $attribute->getName(), 'choices' => CommonFunction::entitiesToFormView($reference->getItems() ?: []), 'required' => false]); break; } } $builder->add(C::FORM_SUBMIT, SubmitType::class, ['label' => 'Готово']); }