0

even doing copy/paste of this constraits, nothing hapens, i have disabled the html validations also, this is the code : twig:

{{form_start(form, {'action':'', 'method':'POST'})}}
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
{{form_end(form)}}

here the class:

class Curso {

/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 * @Assert\MaxLength(15)
 * @ORM\Column(name="titulo", type="string", length=255)
 */
private $titulo;

/**
 * @var string
 * @Assert\NotBlank()
 * @Assert\Length(
 *      min = 2,
 *      max = 50,
 *      minMessage = "Your first name must be at least {{ limit }} characters long",
 *      maxMessage = "Your first name cannot be longer than {{ limit }} characters"
 * )
 * @Assert\Type("string")
 * @ORM\Column(name="descripcion", type="string", length=255)
 */
private $descripcion;

/**
 * @var float
 * @Assert\NotBlank()
 * @ORM\Column(name="precio", type="float")
 */
private $precio;

/**
 * Get id
 * @Assert\NotBlank()
 * @return int
 */
public function getId() {
    return $this->id;
}

/**
 * Set titulo
 *
 * @param string $titulo
 *
 * @return Curso
 */
public function setTitulo($titulo) {
    $this->titulo = $titulo;

    return $this;
}

/**
 * Get titulo
 *
 * @return string
 */
public function getTitulo() {
    return $this->titulo;
}

/**
 * Set descripcion
 *
 * @param string $descripcion
 *
 * @return Curso
 */
public function setDescripcion($descripcion) {
    $this->descripcion = $descripcion;

    return $this;
}

/**
 * Get descripcion
 *
 * @return string
 */
public function getDescripcion() {
    return $this->descripcion;
}

/**
 * Set precio
 *
 * @param float $precio
 *
 * @return Curso
 */
public function setPrecio($precio) {
    $this->precio = $precio;

    return $this;
}

/**
 * Get precio
 *
 * @return float
 */
public function getPrecio() {
    return $this->precio;
}
}

can you tell me what is wrong? sorry about my english, i'm a little rusty :)!!!

3
  • Are you trying to validate your form or not? Why do you include {'attr': {'novalidate': 'novalidate'}}? Commented Oct 18, 2016 at 23:33
  • @Chausser - wouldn't he still reasonably expect the framework to validate server-side, even with the novalidate option passed? @Pablo - can you include the CursoType form, and maybe the controller method that's handling the requests/responses for this action? Commented Oct 19, 2016 at 13:57
  • @CameronHurd You are correct, the novalidate option should only disable the HTML validation but the server should still do the validation. Commented Oct 19, 2016 at 17:49

1 Answer 1

1

You may want to check your app/config.yml and make sure that the you have annotations enabled for validation

framework: 
    ...
    validation: { enable_annotations: true }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.