That didn't seem to work I'm afriad, thinking about it though, could it be that I need to somehow convert
$caseInfo->Contact = $data['Contact'];
into an integer for it to be accepted by the database?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
That didn't seem to work I'm afriad, thinking about it though, could it be that I need to somehow convert
$caseInfo->Contact = $data['Contact'];
into an integer for it to be accepted by the database?
Well I'm off now, but basically that is what I was saying at the beginning... but my concern with your function is that it is getting the right DataObject and performing the update on it... as always Debug::show (or to log file) is you friend debug EVERYTHING and you'll figure it out!
and to confirm I very much doubt DataObject get_by_id, setField or write is broken. I raised a bug on it once and was embarrassed to find I had a it all wrong... if I'd have spent a little more effort debugging...
as swaiba said, it would help to see your myFifth class or just its static $db setup. Because from the screenshot i assume that you set up the contact field as boolean, that would explain why always 1 is saved to the db since both '1' and '2' casted to boolean = true. in your particiular case i would use 'Yes' => 1, 'No' => 0, or change the field type to integer
Thank you both for your help.
Apening, you are exactly right, I had figured this out and as you suspected the column in the database was cast as a boolean rather than an integer. Works perfectly now!