I have a MySQL table with a field (varchar) with a default value like "#ffffff".
To use this default I know that I can use a snippet like this:
$item_details = $this->request->data;
unset($item_details['Item']['position']);
$this->Item->create();
$this->Item->save($item_details);
... in which unset()
and create()
are used to reset a field and use the default value.
What I don't understand: I mostly don't work in the Models/Controllers, because I use cake bake for scaffolding (automatically building Models and Controllers) and try to work only on the Views (templates, ctp). How do I implement such a special handling and prevent the overwriting of the code while scaffolding via cake bake? I was searching for a possibility to put this into the config area, but have not found any helpful information about this.
Maybe there's another idea for a solution to use MySQL default values, when the form input field is empty.
(There's said, that scaffolding is only effective in early project states - this is an early project state. :) )
Thanks in advance.