Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

regarding Model save

Hi all,

In the new INVO sample, the controllers execute save() without parameter $product->save(), and there isn't post data mapping like $products->id = $this->request->getPost("id", "int");, is Phalcon auto mapping the post data to Model by the associate index? Like $_POST["name"] is automatically mapped to the name column.

thanks in advance

edited Dec '14

Hi, I'm a beginer in phalcon yet... but if I understand correctly, in that sample you can see isValid($data,$product) - this way it assigns the data from POST data to $product object like associate index. If you call isValid($data) - it will validate only and no assignment.


Thanks IGonza. I really should at least test the $product before and after the isValid function. I check the doc but it doesn't mention it's also changing the variable, and the function name is "isValid", so I was assuming it's only doing validation.

edited Dec '14

Yes, it is weird that isValid makes change varibles. It must be documented.