November 11, 200817 yr I have created an event registration site using FM server advanced 9 and the php site assistant. I am now styling the registration page and have probably a silly question. How do I get the 'Yes' from my checkboxes to not appear on the web? I am having registrants use checkboxes to list their employment interests and experience. Thanks.
May 11, 200916 yr I'm having the same problem except my checkboxes have a "1" after each one of them (my value list consists of only the "1" value). I suspect it has everything to do with this function, found in fmview.php: function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) { $selected = ""; $fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue)); foreach ($valuelist as $eachvalue) { if (in_array(trim($eachvalue), $fieldValueArray)){ $selected = " checked"; }else{ $selected = ""; } if ($type == "checkbox"){ echo "$eachvalue"; }else{ echo "$eachvalue"; } } }
May 12, 200916 yr Well, I guess the easiest way to do it would be to modify the function (which is seriously messed up by the way)... function getInputChoices($type, $valuelist, $fieldvalue, $fieldName, $echoValue=true) { $selected = ""; $valuedisplay=""; $fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue)); foreach ($valuelist as $eachvalue) { if (in_array(trim($eachvalue), $fieldValueArray)) $selected = " checked"; else $selected = ""; if( $echoValue ) $valuedisplay = $eachValue; if ($type == "checkbox"){ echo "$valuedisplay"; }else{ echo "$valuedisplay"; } } } Then, wherever you see a call to getInputChoices function after the last parameter that's in there by default, add: ,false e.g. getInputChoices("checkbox", "somelist", "somevalue", "someFieldName", false);
May 12, 200916 yr Ahh, thanks for the tip Genx, but I tried that function and got a error saying "Undefined variable: eachValue". I think I fixed that by just including the line $eachValue = ""; directly after the other variables being set as blank, and it almost works, except that now my checkbox looks like a regular text field (pre-populated with a "1"). So, I think I figured out a better way to get rid of the value lists… this method would just require you to designate this: getInputChoices("checkbox_no_label", "somelist", "somevalue", "someFieldName"); instead of this: getInputChoices("checkbox", "somelist", "somevalue", "someFieldName"); As you can see from the code below (compared to my original post above), I had to change the echoed html code to actually spell out 'checkbox' instead of simply calling '$type'. function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) { $selected = ""; $fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue)); foreach ($valuelist as $eachvalue) { if (in_array(trim($eachvalue), $fieldValueArray)){ $selected = " checked"; }else{ $selected = ""; } if ($type == "checkbox_no_label"){ echo ""; }else if ($type == "checkbox"){ echo "$eachvalue"; }else{ echo "$eachvalue"; } } }
May 13, 200916 yr Sorry typo: function getInputChoices($type, $valuelist, $fieldvalue, $fieldName, $echoValue=true) { $selected = ""; $valuedisplay=""; $fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue)); foreach ($valuelist as $eachvalue) { if (in_array(trim($eachvalue), $fieldValueArray)) $selected = " checked"; else $selected = ""; if( $echoValue ) $valuedisplay = $eachvalue; if ($type == "checkbox"){ echo "$valuedisplay"; }else{ echo "$valuedisplay"; } } }
November 19, 20178 yr If you are using booleans, e.g. Yes/No, since 1. Code is processed sequentially 2. Only the last 'checked' answer is used. Therefore put the 'non' answer first but hide it and leave it always checked. The positive answer comes second. <?php $fieldName = 'Privacy_Agreement';?> <?php $fieldValue = $record->getField($fieldName, 0) ; ?> <input type='hidden' name='<?php echo (getFieldFormName($fieldName, 0, $record, true, 'EDITTEXT', 'number')) ;?>' value='No' checked> <input type='checkbox' name='<?php echo (getFieldFormName($fieldName, 0, $record, true, 'EDITTEXT', 'number')-1) ;?>' value='Yes' <?php if ($fieldValue == 'Yes'){ echo 'checked'; } ?>> You can insert whatever text before or after. This works for me- I was searching for how to make a single checkbox work.
Create an account or sign in to comment