Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Wishlist-application
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZAHDI Mohcine
Wishlist-application
Commits
0381d895
Commit
0381d895
authored
2 months ago
by
mohamed
Browse files
Options
Downloads
Patches
Plain Diff
minore
parent
34abac00
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Form/ItemType.php
+8
-8
8 additions, 8 deletions
src/Form/ItemType.php
templates/item/new.html.twig
+14
-9
14 additions, 9 deletions
templates/item/new.html.twig
with
22 additions
and
17 deletions
src/Form/ItemType.php
+
8
−
8
View file @
0381d895
...
@@ -20,11 +20,11 @@ class ItemType extends AbstractType
...
@@ -20,11 +20,11 @@ class ItemType extends AbstractType
->
add
(
'price'
,
NumberType
::
class
,
[
'label'
=>
'Price'
])
->
add
(
'price'
,
NumberType
::
class
,
[
'label'
=>
'Price'
])
->
add
(
'description'
,
TextType
::
class
,
[
'label'
=>
'Description'
])
->
add
(
'description'
,
TextType
::
class
,
[
'label'
=>
'Description'
])
->
add
(
'imageFile'
,
VichImageType
::
class
,
[
->
add
(
'imageFile'
,
VichImageType
::
class
,
[
'label'
=>
'Upload a new image'
,
// ✅ Change le label pour éviter la confusion
'label'
=>
'Upload a new image'
,
'required'
=>
false
,
// ✅ Permet de ne pas forcer un nouvel upload
'required'
=>
false
,
'allow_delete'
=>
false
,
// ✅ Désactive la suppression automatique
'allow_delete'
=>
false
,
'download_uri'
=>
false
,
// ✅ Désactive le lien de téléchargement
'download_uri'
=>
false
,
'image_uri'
=>
false
,
// ✅ Empêche l'affichage de l'image dans l'input
'image_uri'
=>
false
,
]);
]);
}
}
...
@@ -32,9 +32,9 @@ class ItemType extends AbstractType
...
@@ -32,9 +32,9 @@ class ItemType extends AbstractType
{
{
$resolver
->
setDefaults
([
$resolver
->
setDefaults
([
'data_class'
=>
Item
::
class
,
'data_class'
=>
Item
::
class
,
'csrf_protection'
=>
true
,
// ✅ Active la protection CSRF
'csrf_protection'
=>
true
,
'csrf_field_name'
=>
'_token'
,
// ✅ Définit le nom du champ CSRF
'csrf_field_name'
=>
'_token'
,
'csrf_token_id'
=>
'submit'
,
// ✅ Identifie le token
'csrf_token_id'
=>
'submit'
,
]);
]);
}
}
}
}
This diff is collapsed.
Click to expand it.
templates/item/new.html.twig
+
14
−
9
View file @
0381d895
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
font-size
:
1rem
;
font-size
:
1rem
;
cursor
:
pointer
;
cursor
:
pointer
;
transition
:
0.3s
;
transition
:
0.3s
;
margin-top
:
15px
;
}
}
.btn
:hover
{
.btn
:hover
{
background-color
:
#99CC33
;
background-color
:
#99CC33
;
...
@@ -87,15 +88,19 @@
...
@@ -87,15 +88,19 @@
<div
class=
"container"
>
<div
class=
"container"
>
<section
class=
"form-section"
>
<section
class=
"form-section"
>
{{
form_start
(
form
,
{
'attr'
:
{
'class'
:
'input-box'
}}
) }}
{{
form_start
(
form
,
{
'attr'
:
{
'class'
:
'input-box'
}}
) }}
{{
form_row
(
form.title
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.url
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.title
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.price
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.url
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.description
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.price
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
{{
form_row
(
form.description
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
<h3>
Item Image
</h3>
{{
form_row
(
form.imageFile
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
<h3
style=
"margin-top: 20px;"
>
Item Image
</h3>
{{
form_row
(
form.imageFile
,
{
'attr'
:
{
'class'
:
'form-control'
}}
) }}
<button
class=
"btn"
>
Confirm
</button>
{{
form_rest
(
form
)
}}
{# ✅ Inclut le token CSRF ici #}
<button
class=
"btn"
type=
"submit"
>
Confirm
</button>
{{
form_end
(
form
)
}}
{{
form_end
(
form
)
}}
</section>
</section>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment