Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mathieu
technobel.sf
Commits
730f14ed
Commit
730f14ed
authored
May 19, 2018
by
Mat
Browse files
ajoute une contrainte sur les champs, on déclenche bien une 400
il manquait un use dans le controller
parent
37c0a30b
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/APIBundle/Controller/OwnerAPIController.php
View file @
730f14ed
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
APIBundle\Controller
;
namespace
APIBundle\Controller
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Request
;
use
APIBundle\Form\Owner\OwnerAPIType
;
use
APIBundle\Form\Owner\OwnerAPIType
;
...
...
src/APIBundle/Form/Owner/OwnerAPIType.php
View file @
730f14ed
...
@@ -19,7 +19,7 @@ class OwnerAPIType extends OwnerType
...
@@ -19,7 +19,7 @@ class OwnerAPIType extends OwnerType
// ok, on met ça en développement, le temps de régler
// ok, on met ça en développement, le temps de régler
// les validations au niveau des Asserts, des FormType,
// les validations au niveau des Asserts, des FormType,
// qd c'est réglé, on vire cette option !!!
(false)
// qd c'est réglé, on vire cette option !!!
$resolver
->
setDefault
(
'attr'
,
array
(
'novalidate'
=>
true
));
$resolver
->
setDefault
(
'attr'
,
array
(
'novalidate'
=>
true
));
}
}
...
...
src/TechnoBundle/Entity/Owner.php
View file @
730f14ed
...
@@ -4,6 +4,7 @@ namespace TechnoBundle\Entity;
...
@@ -4,6 +4,7 @@ namespace TechnoBundle\Entity;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Symfony\Component\Validator\Constraints
as
Assert
;
/**
/**
* Owner
* Owner
...
@@ -27,6 +28,12 @@ class Owner
...
@@ -27,6 +28,12 @@ class Owner
* @var string
* @var string
*
*
* @ORM\Column(name="Lastname", type="string", length=100)
* @ORM\Column(name="Lastname", type="string", length=100)
* @Assert\Length(
* min = 3,
* max = 50,
* minMessage = "Your first name must be at least {{ limit }} characters long",
* maxMessage = "Your first name cannot be longer than {{ limit }} characters"
* )
*/
*/
private
$lastname
;
private
$lastname
;
...
@@ -34,6 +41,12 @@ class Owner
...
@@ -34,6 +41,12 @@ class Owner
* @var string
* @var string
*
*
* @ORM\Column(name="Firstname", type="string", length=100)
* @ORM\Column(name="Firstname", type="string", length=100)
* @Assert\Length(
* min = 3,
* max = 50,
* minMessage = "Your first name must be at least {{ limit }} characters long",
* maxMessage = "Your first name cannot be longer than {{ limit }} characters"
* )
*/
*/
private
$firstname
;
private
$firstname
;
...
...
src/TechnoBundle/Resources/views/Ajax/Owner/mainDisplay.html.twig
View file @
730f14ed
...
@@ -195,10 +195,7 @@
...
@@ -195,10 +195,7 @@
form
.
addEventListener
(
'
submit
'
,
function
(
e
)
form
.
addEventListener
(
'
submit
'
,
function
(
e
)
{
{
let
form
=
this
;
let
form
=
this
;
e
.
preventDefault
();
// Annule l'événement, mais préserve la fonction callback
// Annule l'événement, mais préserve la fonction callback
e
.
preventDefault
();
postAJAX
(
submitURL
,
function
()
postAJAX
(
submitURL
,
function
()
{
{
if
(
this
.
readyState
===
4
)
if
(
this
.
readyState
===
4
)
...
@@ -209,7 +206,13 @@
...
@@ -209,7 +206,13 @@
form
.
parentNode
.
classList
.
add
(
'
hidden
'
);
form
.
parentNode
.
classList
.
add
(
'
hidden
'
);
}
else
if
(
this
.
status
===
400
)
{
}
else
if
(
this
.
status
===
400
)
{
console
.
log
(
'
BAD REQUEST. DISPLAY ERRORS
'
);
console
.
log
(
'
400 Bad Request
'
);
}
else
if
(
this
.
status
===
404
)
{
console
.
log
(
'
404 Not Found
'
);
}
else
if
(
this
.
status
===
500
)
{
console
.
log
(
'
500 Internal Server Error
'
);
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment