From: Florianschmidtwelzow Date: Wed, 28 Oct 2015 14:39:39 +0000 (+0100) Subject: HTMLRadioField: Use another variable for the radio value to avoid conflicts X-Git-Tag: 1.31.0-rc.0~9191 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=46ab7a82908933454c43259cf7e1fae1f316e51f;p=lhc%2Fweb%2Fwiklou.git HTMLRadioField: Use another variable for the radio value to avoid conflicts $value is used in a foreach loop to build the radioselect fields array for OOUI, but $value is also the variable, which holds the default value for the element (or a value, which ws submitted by the user), to pre-select the correct radio input field. That results in the problem, that $value will always contain the last data, which passed the foreach loop, and always the last radio input field will be pre- selected, no matter, what the developer defined as the default or what the user submitted in a prior form instance. Change the variable used in the foreach loop to avoid this conflict. Change-Id: I36c760be8ccd86e75249c966f697b499576c83d4 --- diff --git a/includes/htmlform/HTMLRadioField.php b/includes/htmlform/HTMLRadioField.php index 19b45bea17..2d057042ef 100644 --- a/includes/htmlform/HTMLRadioField.php +++ b/includes/htmlform/HTMLRadioField.php @@ -40,9 +40,9 @@ class HTMLRadioField extends HTMLFormField { function getInputOOUI( $value ) { $options = array(); - foreach ( $this->getOptions() as $label => $value ) { + foreach ( $this->getOptions() as $label => $data ) { $options[] = array( - 'data' => $value, + 'data' => $data, 'label' => $this->mOptionsLabelsNotFromMessage ? new OOUI\HtmlSnippet( $label ) : $label, ); }