Skip to content
Snippets Groups Projects
Commit 6303b681 authored by Axel Po's avatar Axel Po
Browse files

categorie

parent 9f88f40f
2 merge requests!6Dev,!3Feat/categories
......@@ -76,3 +76,4 @@ class CategoryController extends AbstractController
return $this->redirectToRoute('app_category_index', [], Response::HTTP_SEE_OTHER);
}
}
......@@ -9,17 +9,34 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class ProductType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('description')
->add('price')
->add('imageSrc')
;
->add('title', Product::class, [
'label' => 'Title',
'attr' => ['class' => 'form-control']
])
->add('description', TextareaType::class, [
'label' => 'Description',
'attr' => ['class' => 'form-control']
])
->add('price', Product::class, [
'label' => 'Price',
'attr' => ['class' => 'form-control']
])
->add('imageSrc', Product::class, [
'label' => 'Image',
'attr' => ['class' => 'form-control']
])
->add('category', EntityType::class, [
'label' => 'Category',
'class' => Category::class,
'choice_label' => 'name',
'attr' => ['class' => 'form-control']
]);
}
public function configureOptions(OptionsResolver $resolver): void
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Product::class,
......
......@@ -66,7 +66,7 @@
<a
class="bg-red-500 text-white py-2 px-6 rounded-md"
href="{{ path('app_product_index_admin') }}"
>Admin</a
>Accès Admin</a
>
{% endif %} {% else %} {% if app.user %}
<a class="bg-[#F5B100] py-2 px-6 rounded-md" href="#"
......@@ -89,5 +89,6 @@
<p>BUT MMI2 - INFO4</p>
</div>
</footer>
</body>
</html>
......@@ -18,6 +18,8 @@
}}) }}
{{ form_row(form.category, {'label': 'Category', 'attr': {'class': 'p-2 rounded-lg border flex w-full text-black'}}) }}
{{ form_widget(form) }}
<div>
<button class="bg-blue-400 text-white py-2 px-6 rounded-md">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment