We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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



10.7k
Accepted
answer
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.



25.7k

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.



2.2k
edited Dec '14

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