I'm using the Phalcon framework for PHP, and I would like to save my form into the database, all is working how is supposed to, but I can't save empty strings in some (not required) fields.
How can I save not required field? Every time I save not required fields without input, I get an error like "lastname field is required.".
Anyone?
Sorry, my English is not good, I'm learning...
My controller code is:
$this->view->disable();
$usuario = new Usuarios();
$usuario->usuario = $this->request->getPost("usuario");
$usuario->email = $this->request->getPost("email");
$usuario->senha = $this->request->getPost("senha");
$usuario->nome = $this->request->getPost("nome");
$usuario->sobrenome = $this->request->getPost("sobrenome");
$usuario->icone = $this->request->getPost("icone");
$usuario->fixo = $this->request->getPost("fixo");
$usuario->celular = $this->request->getPost("celular");
$usuario->tipo = $this->request->getPost("tipo");
$usuario->save();
And I have basic validations in my model...
You can choose one of the these solution which suggested on How to make models use defaults in Phalcon PHP Framework?
Last and simple solution:
$usuario->usuario = $this->request->getPost("usuario") || "";