Open ahashesht opened 1 year ago
Since setDefault()
is for setting the initial value of the value attribute, it will not work as expected.
(However, I can understand your expectations...)
With the idea of reversal, if you do the following, it will work even in the current version. I found it while trying various things.
$elm = new Element\Check('testcb', ['checked' => '1',]);
$elm->setDefault(1);
$this->add($elm);
However, this was no good.
$elm = new Element\Check('testcb', ['checked' => 1,]);
$elm->setDefault(1);
$this->add($elm);
And although this result seems strange,
$elm = new Element\Check('testcb', ['value' => 1,]);
$this->add($elm);
{{ form.render('testcb', ['checked' : 1]) }}
is OK but
{{ form.render('testcb', ['checked' : '1']) }}
is NG.
There are some Problems with the checkbox and radio Tags (like always)
checked
attribute to checked
, this should be honored before anything else. Currently there is no check for this at all.Proposal:
checked
is set to checked
and treat it as such. There is no need to check anything anymore.strcmp
and cast both the values to string
, if it's not an object or array, to increase the matching.
Referencing this line:
https://github.com/phalcon/cphalcon/blob/e01ae9b5a2412be4bcac0772f2ec7463b2f2f960/phalcon/Html/Helper/Input/Checkbox.zep#L117
Assuming I create my checkbox like this:
Then the rendered checkbox will not be checked by default! Is this by design? In Phalconv4 there was a method called
prepareAttributes
that handled assigned the correctchecked
attribute. I believechecked
should be set in this case.