Replies: 1 comment
-
The result has changed because a modification has been made to allow 0 as a value. <input type="checkbox" id="test1" name="test1" value="0" />
<input type="checkbox" id="test2" name="test2" value="0" />
<input type="checkbox" id="test3" name="test3" value="1" />
<input type="checkbox" id="test4" name="test4" value="1" />
<input type="checkbox" id="test5" name="test5" value="0" checked="checked" />
<input type="checkbox" id="test6" name="test6" value="0" />
<input type="checkbox" id="test7" name="test7" value="1" />
<input type="checkbox" id="test8" name="test8" value="1" checked="checked" />
<input type="checkbox" id="test9" name="test9" value="01" checked="checked" />
<input type="checkbox" id="testA" name="testA" value="01" />
<input type="checkbox" id="testB" name="testB" value="on" checked="checked" />
<input type="checkbox" id="testC" name="testC" value="on" />
<input type="checkbox" id="testD" name="testD" value="off" />
<input type="checkbox" id="testE" name="testE" value="off" checked="checked" />
<input type="checkbox" id="testF" name="testF" value="1" checked="checked" />
<input type="checkbox" id="testG" name="testG" value="1" checked="checked" /> I also looked into using $elm = new Element\Check('testCb1', ['checked' => '1', 'value' => 1]);
$this->add($elm);
$elm = new Element\Check('testCb2', ['checked' => '1', 'value' => '1']);
$this->add($elm);
$elm = new Element\Check('testCb3', ['checked' => 1, 'value' => 1]);
$this->add($elm);
$elm = new Element\Check('testCb4', ['checked' => 1, 'value' => '1']);
$this->add($elm);
$elm = new Element\Check('testCb5', ['checked' => '1']);
$elm->setDefault(1);
$this->add($elm);
$elm = new Element\Check('testCb6', ['checked' => '1']);
$elm->setDefault('1');
$this->add($elm);
$elm = new Element\Check('testCb7', ['checked' => 1]);
$elm->setDefault(1);
$this->add($elm);
$elm = new Element\Check('testCb8', ['checked' => 1]);
$elm->setDefault('1');
$this->add($elm);
$elm = new Element\Check('testCb9', ['value' => '1']);
$elm->setDefault(1);
$this->add($elm);
$elm = new Element\Check('testCbA', ['value' => '1']);
$elm->setDefault(1);
$this->add($elm);
$elm = new Element\Check('testCbB', ['value' => 1]);
$elm->setDefault('1');
$this->add($elm);
$elm = new Element\Check('testCbC', ['value' => 1]);
$elm->setDefault('1');
$this->add($elm); in .volt {{ form.render('testCb1') }}
{{ form.render('testCb2') }}
{{ form.render('testCb3') }}
{{ form.render('testCb4') }}
{{ form.render('testCb5') }}
{{ form.render('testCb6') }}
{{ form.render('testCb7') }}
{{ form.render('testCb8') }}
{{ form.render('testCb1',['checked':1]) }}
{{ form.render('testCb1',['checked':'1']) }}
{{ form.render('testCb2',['checked':1]) }}
{{ form.render('testCb2',['checked':'1']) }}
{{ form.render('testCb3',['checked':1]) }}
{{ form.render('testCb3',['checked':'1']) }}
{{ form.render('testCb4',['checked':1]) }}
{{ form.render('testCb4',['checked':'1']) }}
{{ form.render('testCb5',['checked':1]) }}
{{ form.render('testCb5',['checked':'1']) }}
{{ form.render('testCb6',['checked':1]) }}
{{ form.render('testCb6',['checked':'1']) }}
{{ form.render('testCb7',['checked':1]) }}
{{ form.render('testCb7',['checked':'1']) }}
{{ form.render('testCb8',['checked':1]) }}
{{ form.render('testCb8',['checked':'1']) }}
{{ form.render('testCb9',['checked':1]) }}
{{ form.render('testCb9',['checked':'1']) }}
{{ form.render('testCbA',['checked':1]) }}
{{ form.render('testCbA',['checked':'1']) }}
{{ form.render('testCbB',['checked':1]) }}
{{ form.render('testCbB',['checked':'1']) }}
{{ form.render('testCbC',['checked':1]) }}
{{ form.render('testCbC',['checked':'1']) }} The above will generate the following: <input type="checkbox" id="testCb1" name="testCb1" value="1" />
<input type="checkbox" id="testCb2" name="testCb2" value="1" checked="checked" />
<input type="checkbox" id="testCb3" name="testCb3" value="1" checked="checked" />
<input type="checkbox" id="testCb4" name="testCb4" value="1" />
<input type="checkbox" id="testCb5" name="testCb5" value="1" checked="checked" />
<input type="checkbox" id="testCb6" name="testCb6" value="1" checked="checked" />
<input type="checkbox" id="testCb7" name="testCb7" value="1" />
<input type="checkbox" id="testCb8" name="testCb8" value="1" />
<input type="checkbox" id="testCb1" name="testCb1" value="1" checked="checked" />
<input type="checkbox" id="testCb1" name="testCb1" value="1" />
<input type="checkbox" id="testCb2" name="testCb2" value="1" />
<input type="checkbox" id="testCb2" name="testCb2" value="1" checked="checked" />
<input type="checkbox" id="testCb3" name="testCb3" value="1" checked="checked" />
<input type="checkbox" id="testCb3" name="testCb3" value="1" />
<input type="checkbox" id="testCb4" name="testCb4" value="1" />
<input type="checkbox" id="testCb4" name="testCb4" value="1" checked="checked" />
<input type="checkbox" id="testCb5" name="testCb5" value="1" />
<input type="checkbox" id="testCb5" name="testCb5" value="1" checked="checked" />
<input type="checkbox" id="testCb6" name="testCb6" value="1" />
<input type="checkbox" id="testCb6" name="testCb6" value="1" checked="checked" />
<input type="checkbox" id="testCb7" name="testCb7" value="1" />
<input type="checkbox" id="testCb7" name="testCb7" value="1" checked="checked" />
<input type="checkbox" id="testCb8" name="testCb8" value="1" />
<input type="checkbox" id="testCb8" name="testCb8" value="1" checked="checked" />
<input type="checkbox" id="testCb9" name="testCb9" value="1" />
<input type="checkbox" id="testCb9" name="testCb9" value="1" checked="checked" />
<input type="checkbox" id="testCbA" name="testCbA" value="1" />
<input type="checkbox" id="testCbA" name="testCbA" value="1" checked="checked" />
<input type="checkbox" id="testCbB" name="testCbB" value="1" checked="checked" />
<input type="checkbox" id="testCbB" name="testCbB" value="1" />
<input type="checkbox" id="testCbC" name="testCbC" value="1" checked="checked" />
<input type="checkbox" id="testCbC" name="testCbC" value="1" /> If It is possible to override I think it's confusing that depending on what value to set, there are cases where you can specify it easily and cases where you have to specify it strictly. |
Beta Was this translation helpful? Give feedback.
-
I'm trying Phalcon 5.0.0RC4.
I'm trying to generate a checkbox, but I can't get it to be "checked" as expected.
So I tried these
I have generated HTML like this.
The value attribute value can't distinguish between letters and numbers when sent over http, so it's no wonder that the value parameter of inputCheckbox() seems to be cast to a string.
However, if both the value parameter and checked parameter are '0', I don't think it works as expected.
('1' works as expected)
What do you guys think?
There may be no change in the specifications around here from past versions, but I want '0' to be valid as well.
(Because "not sent" and "0 sent" as form data are different things)
And I think it should be specified in the manual that "checked parameters are only strings".
Also, I think it should be announced that "value parameters should not be given other than strings".
With literals you could pay attention to the above, but with variables it's easy to make mistakes.
Beta Was this translation helpful? Give feedback.
All reactions