[FX.php List] Editing Checkboxes
Derrick Fogle
derrick at fogles.net
Mon Oct 23 15:16:04 MDT 2006
FYI, I get proper de-selection of checkboxes in an FM database
without doing anything special in the PHP code. Here's how it works
for me:
For any single-item checkbox in FM, I always use a number field, and
the value is always either a 1 or nothing/null. Then I do an:
$instance -> AddDBParam('checkboxfield',$submittedcheckbox);
...in my PHP code for a record update. If the checkbox was previously
checked and the user un-checked the box on the web form, it is true
that the $submittedcheckbox variable does not even exist. But,
setting the FM field to a non-existent variable really does set the
field to nothing/null, rather than leaving the previous value.
It's only when I have a multi-value checkbox (which I usually stay
away from) that the code becomes more difficult, but I've still never
had to explicitly set a un-checked checkbox value to 0 or null to
submit it to FM. Instead, just assemble the checked values into a
return (\r) -delimited variable, and set the FM field to that
variable. That should completely replace any existing values, not
simply add to or change them.
I also recommend making sure any fields used for data input from PHP
should not have any formatting (checkboxes, popup lists, etc.) at
all. They should all be plain entry fields. You shouldn't need them
because you're already using another interface (web form) to limit
data input the same way as an FM checkbox or popup would.
Derrick Fogle
derrick at fogles.net
More information about the FX.php_List
mailing list