Testing, getting and setting checkbox values

A place for users and developers of the Xataface to discuss and receive support.

Testing, getting and setting checkbox values

Postby Martin Dowse » Fri Aug 06, 2010 3:20 pm

Hi

what is the recommended way of testing, getting and setting values stored in widget:type=checkbox fields? Is there a way to use $record->valueChanged, $record->val and $record->setValue with individual fields within the checkbox array?

Thanks

Martin

PS: Apologies if this post turns up twice - I thought I had posted it last night but I can't see it now so here it is again.
Martin Dowse
 
Posts: 12
Joined: Mon Aug 04, 2008 4:42 pm

Re: Testing, getting and setting checkbox values

Postby shannah » Wed Aug 11, 2010 10:44 am

I always forget exactly how they're stored... I think these fields are stored as associative arrays. The best way to check is to do a print_r on output of the val() method for the particular field.
e.g.
Code: Select all
print_r($record->val('my_checkbox_field'));


The valueChanged() method will return true if ANY of the values have changed. You can compare the changes by comparing getSnapshot() with getValues().

e.g.
Code: Select all
$snapshot = $record->getSnapshot();
$current = $record->getValues();
$oldFieldVal = $snapshot['my_field'];
$currFieldVal = $current['my_field'];


or something along those lines.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Testing, getting and setting checkbox values

Postby Martin Dowse » Wed Aug 11, 2010 12:51 pm

Thanks - that will do the job.
Martin Dowse
 
Posts: 12
Joined: Mon Aug 04, 2008 4:42 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved