Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Phalcon 2.0.9] Radio field unchecked if default value is 0 #11358

Closed
Jeffzor opened this issue Feb 2, 2016 · 2 comments
Closed

[Phalcon 2.0.9] Radio field unchecked if default value is 0 #11358

Jeffzor opened this issue Feb 2, 2016 · 2 comments
Labels
bug A bug report status: medium Medium

Comments

@Jeffzor
Copy link

Jeffzor commented Feb 2, 2016

Hello,

Using PHP 5.6.2, when I set a default value to 0, no radio fields are checked.

/*
 Class someClass 
*/
class someClass extends \Phalcon\Mvc\Controller
{
    public function someFunction()
    {
        $this->tag->setDefault('someRadioButton', 0);
    }
}

When I set my radio fields in the view:

$this->tag->radioField(array('someRadioButton', 'id' => 'someRadio0', 'value' => 0));
$this->tag->radioField(array('someRadioButton', 'id' => 'someRadio1', 'value' => 1));

No radio fields are checked.

It happens just with values 0, '0' and '' (actually all values that are interpreted as false in PHP).

In the tag.zep file, the protected method "_inputFieldChecked", a condition causes the problem (lines 539 and 549):

if value && currentValue == value {
                let params["checked"] = "checked";
}
/**
* Evaluate the value in POST
*/
if value {
    let params["checked"] = "checked";
}

The condition "if value" with those values is not working properly (never enters in the condition).
I should be able to create Radio fields with these default values without problem.

It should be like in PHP :

if (isset($value))

It would be great if you could fixed it.

Thanks!
Jeff

@bmoore
Copy link
Contributor

bmoore commented Feb 16, 2016

#11412

sergeyklay added a commit that referenced this issue Feb 16, 2016
@sergeyklay
Copy link
Contributor

Fixed in 2.1.x

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

4 participants