Example #1
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $data = $options['data'];
     $builder->add(C::FORM_TITLE, TextType::class, ['label' => 'Новый аттрибут', 'required' => true]);
     $builder->add(C::FORM_COMMENT, TextType::class, ['label' => 'Комментарий', 'required' => false]);
     $builder->add(C::FORM_ATTRIBUTE_TYPE, ChoiceType::class, ['label' => 'Тип', 'choices' => ProductAttribute::getTypesList(true), 'required' => true]);
     $builder->add(C::FORM_REFERENCE, ChoiceType::class, ['label' => 'Список', 'choices' => $data[C::FORM_REFERENCE_LIST], 'required' => true]);
     $builder->add(C::FORM_SUBMIT, SubmitType::class, ['label' => 'Добавить']);
 }
Example #2
0
 public function listAttributesAction(Request $request)
 {
     $model = $this->get(C::MODEL_ADMIN);
     $form = $this->createForm(NewAttributeForm::class, [C::FORM_REFERENCE_LIST => $model->getAttrReferencesForForm()]);
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         $formData = $form->getData();
         try {
             $model->createOrUpdateProductAttribute($formData);
             $this->addFlash(C::FLASH_SUCCESS, 'ok!');
             return $this->redirectToThis();
         } catch (\Exception $e) {
             $this->addFlash(C::FLASH_ERROR, $e->getMessage());
             throw $e;
         }
     }
     return $this->render('@Velovito/admin/list_attributes.html.twig', ['attributeTypes' => ProductAttribute::getTypesList(), 'items' => $model->getAlLProductAttributes(), 'form' => $form->createView()]);
 }