the new variable, only the new did not write to DB (everything else did). It was present in $_POST[‘message’] array, in debug window was insert into DB without that one field. Did some research, only method that worked, was
By the way, I have a problem we I update my model. In the form’s model there isn’t fields that updates the model. All the data is calculate with others values that are in the form.
Because of that, the $_POST[‘MODEL’] is unsset. I removed the line of code that check if the $_POST[‘MODEL’] is set.
Then I load the model and update one value and save. But the model doesn’t wanna save. The database is unchanged.
has the attribute save something in commonm with my problem??
All fields not listed in rules() are unsafe by default, so, if no special treatment need some field, but it IS safe, then this rule "safe" enters in action.
Since I am also running into these issues after upgrading I thought I’d comment. Perhaps it would be better to have the default for all fields be safe and allow the developer to mark which fields should not be safe. The majority of all my fields in all my tables are going to be populated by the user. DateEntered fields, Key fields or the like would be the exception. Springing this type of change with a much anticipated release has been frustrating.
At this point all my forms are broken. The project I’ve been working on for about five weeks is the blog demo that came with my original install and I’ve followed it closely. So, either the demo doesn’t adhere to the “rules” very well or there should be more DOCS on the importance of making attributes “SAFE” or else… Not to mention how to actually use them properly in different scenarios. Sorry to vent but I’ve pretty much wasted my entire weekend working on this upgrade… just when I thought I was beginning to make some progress on this stuff.
Current patter is way better and safer. In real world you do not always need to populate all fields with massive assignements, like $model->attributes = $_POST[‘Model’]; There are attributes which in many cases should not be modified such way (for example - when updating users profile you do not want to change password, even if someone passes proper attribute in request. You have additional procedure to change password, which validates if user knows previous one, etc. Otherwise - hacker could easily change someones password. Now - people (coders also) are lazy, so if you relay on them to mark attributes “unsafe” in scenario when all atributes are “safe” by default you will end with everything left as generators did produce and your application unsafe and with real security holes. This is why everything is “unsafe” by default and you have to provide other rules.
In fact - you do not always need to specify attribute as “safe”, any other validation rule will do the same (for example: required, match, etc). This behavior forces you to provide validators, which is good