Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Radio buttons don't check if bound to subdocument #668

Closed
wants to merge 1 commit into from

3 participants

@giacmir

As in the object I noticed that if a radio button set is bound to a subdocument using a dot notation (e.g. person.name) it doesn't checks.

This happens because the $name variable passed is changed before the value check and so it always fails.

@nateabele
Owner

Thanks for the fix! We accept pull requests against the dev branch, and will merge it once it has an accompanying test case that proves the issue. You can refer to our contributor guide for more information: http://lithify.me/docs/manual/appendices/contributing.wiki

@ericcholis

Since this has been floating for a little while, I'd be happy to re-submit against the latest dev and write tests.

Any thoughts on where to place the tests? I figured I it would be best to just extend:

lithium\tests\cases\template\helper\FormTest->testRadioGeneration();
lithium\tests\cases\template\helper\FormTest->testCustomRadio();
lithium\tests\cases\template\helper\FormTest->testCustomValueRadio();

to account for dot-notation names. Thought I would check first.

@nateabele
Owner

@ericcholis That would be most appreciated, thanks. Extending those existing tests sounds fine.

@ericcholis

All set, opened a new issue #815

@nateabele
Owner

Closing in favor of #815. Thanks @ericcholis.

@nateabele nateabele closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 template/helper/Form.php
View
5 template/helper/Form.php
@@ -670,11 +670,12 @@ public function radio($name, array $options = array()) {
$defaults = array('value' => '1');
$options += $defaults;
$default = $options['value'];
+ $key = $name;
list($name, $options, $template) = $this->_defaults(__FUNCTION__, $name, $options);
list($scope, $options) = $this->_options($defaults, $options);
- if (!isset($options['checked']) && ($bound = $this->binding($name)->data)) {
+ if (!isset($options['checked']) && ($bound = $this->binding($key)->data)) {
$options['checked'] = ($bound == $default);
}
@@ -857,4 +858,4 @@ protected function _generators($method, $name, $options) {
}
}
-?>
+?>
Something went wrong with that request. Please try again.