Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] OptionsetField not saving, please help


Go to End


12 Posts   3424 Views

Avatar
Harley

Community Member, 165 Posts

8 January 2011 at 5:57am

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?

Avatar
swaiba

Forum Moderator, 1899 Posts

8 January 2011 at 6:04am

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...

Avatar
apiening

Community Member, 60 Posts

11 January 2011 at 11:36am

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

Avatar
Harley

Community Member, 165 Posts

11 January 2011 at 11:40am

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!

Go to Top