Welcome Guest, Not a member yet? Register   Sign In
A check if model has anything to update
#7

(04-17-2022, 11:46 PM)kenjis Wrote: Entity class is simply a class that represents a single database row.
I know.

(04-17-2022, 11:46 PM)kenjis Wrote: You should fill only database fields.
That means I need to manually filter POST data. It means more code, more logic, some code duplication. Model already knows allowed fields and has filtering code. I'd expect to get some helper so I don't have to handle checking for changes on my own.

(04-17-2022, 11:46 PM)kenjis Wrote: Why do you need to fill "agree" & "submit"?

  1. I need to make sure user agreed with site rules
  2. My form has "Save" and "Delete" buttons so I need "submit" name for submit input and "remove" for the other.
  3. There are actually even more extra fields in my form as I also have "foo_bars" table. So my POST actually looks like:
    Code:
    [
        'name' => 'John',
        'bars' => [
            '0' => 'red',
            '1' => 'green',
            '2' => 'blue',
        ],
        'agree' => '1',
        'submit' => 'Save',
    ];
Reply


Messages In This Thread
RE: A check if model has anything to update - by rmilecki - 04-18-2022, 02:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB