Open sidebar
<?php namespace App\Form; use App\Entity\Category; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class CategoryType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', null, [ 'attr' => ['class' => 'form-control'], ]) ->add('slug', null, [ 'attr' => ['class' => 'form-control'], ]) ->add('parent_id', EntityType::class, [ 'class' => Category::class, 'choice_label' => 'name', 'attr' => ['class' => 'form-control'], 'placeholder' => 'Üst Kategori Seçiniz', ]) ->add('title', null, [ 'attr' => ['class' => 'form-control'] ]) ->add('description', null, [ 'attr' => ['class' => 'form-control'] ]) ; } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => Category::class, 'required' => false ]); } }
Close sidebar
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
X (fomerly Twitter)
GitHub
Use setting