Quote from: BobRay at Mar 10, 2011, 09:55 PM
You should be able to make a checkbox checked by adding a [[+checked]] placeholder in the form:
<input type="checkbox" [[+checked] name="whatever" ... etc.>
Then put a snippet above the form that does this, but only when the form first loads:
$modx->setPlaceholder('checked', 'checked="checked"');
Well, that is almost exactly that I did. But it might be better if FormIt will support checkboxex checked by default itself. For example with [[!+fi.checkboxname:FormItIsChecked=`Yes||default`]] syntax or something like this.
And moreover... PHP doesn’t send any value if checkbox is unchecked. If I have:
<input type="checkbox" id="whatever" name="whatever" value="Yes" [[!+fi.whatever:FormItIsChecked=`Yes`]] />
I will receive ’Yes’ in [[+whatever]] in my email template if checkbox was checked and nothing if it was not. But I want to have ’No’ in [[+whatever]] if checkbox was unchecked.
The FormIt math hook should probably make sure the answer isn’t 0. Could you file that as a bug?
Well, the answer is 0 is not a problem, the problem is 0 equals null or empty string somewhere in FormIt math. And I think it’s because of using functions without checking variable type like == and != instead of === and !== when input value is checking.