Fix accesibility problem with radiogroups and checkgroups populated by query

This commit is contained in:
Julio Cesar Laura
2012-10-17 13:48:49 -04:00
parent ce7bf2d0c2
commit 10318164c5

View File

@@ -3101,7 +3101,7 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field {
if( isset($this->linkType) && ($this->linkType == 1 || $this->linkType == "1") ){ if( isset($this->linkType) && ($this->linkType == 1 || $this->linkType == "1") ){
$html .= '<input id="form['.$this->name.']['.$optionName.']" name="form['.$this->name.']" type="radio" value="'.$optionName.'" '.(($optionName==$value) ? ' checked' : '') . '><a href="#" onclick="executeEvent(\'form['.$this->name.']['.$optionName.']\', \'click\'); return false;">' . $option . '</a></input>'; $html .= '<input id="form['.$this->name.']['.$optionName.']" name="form['.$this->name.']" type="radio" value="'.$optionName.'" '.(($optionName==$value) ? ' checked' : '') . '><a href="#" onclick="executeEvent(\'form['.$this->name.']['.$optionName.']\', \'click\'); return false;">' . $option . '</a></input>';
} else { } else {
$html .= '<input id="form['.$this->name.']['.$optionName.']" name="form['.$this->name.']" type="radio" value="'.$optionName.'" '.(($optionName==$value) ? ' checked' : '') . '>' . $option . '</input>'; $html .= '<input id="form['.$this->name.']['.$optionName.']" name="form['.$this->name.']" type="radio" value="'.$optionName.'" '.(($optionName==$value) ? ' checked' : '') . '><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></input>';
} }
if(++$i==count($this->options)){ if(++$i==count($this->options)){
$html .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$this->renderHint(); $html .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$this->renderHint();
@@ -3117,7 +3117,7 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field {
} elseif ($this->mode === 'view') { } elseif ($this->mode === 'view') {
$html = ''; $html = '';
foreach ( $this->options as $optionName => $option ) { foreach ( $this->options as $optionName => $option ) {
$html .= '<input class="module_app_input___gray" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . ']" type=\'radio\' value="' . $optionName . '" ' . (($optionName == $value) ? 'checked' : '') . ' disabled><span class="FormCheck">' . $option . '</span></input><br>'; $html .= '<input class="module_app_input___gray" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . ']" type=\'radio\' value="' . $optionName . '" ' . (($optionName == $value) ? 'checked' : '') . ' disabled><span class="FormCheck"><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></span></input><br>';
if($optionName == $value) if($optionName == $value)
$html .= '<input type="hidden" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . ']" value="' . (($optionName == $value) ? $optionName : '') . '">'; $html .= '<input type="hidden" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . ']" value="' . (($optionName == $value) ? $optionName : '') . '">';
} }
@@ -3198,7 +3198,7 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field
$i=0; $i=0;
$html = ''; $html = '';
foreach ( $this->options as $optionName => $option ) { foreach ( $this->options as $optionName => $option ) {
$html .= '<input id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array ( $optionName, $value ) ? 'checked' : '') . '><span class="FormCheck">' . $option . '</span></input>'; $html .= '<input id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array ( $optionName, $value ) ? 'checked' : '') . '><span class="FormCheck"><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></span></input>';
if(++$i==count($this->options)){ if(++$i==count($this->options)){
$html .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$this->renderHint(); $html .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$this->renderHint();
} }
@@ -3208,7 +3208,7 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field
} elseif ($this->mode === 'view') { } elseif ($this->mode === 'view') {
$html = ''; $html = '';
foreach ( $this->options as $optionName => $option ) { foreach ( $this->options as $optionName => $option ) {
$html .= '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array ( $optionName, $value ) ? 'checked' : '') . ' disabled><span class="FormCheck">' . $option . '</span></input><br>'; $html .= '<input class="FormCheck" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" type=\'checkbox\' value="' . $optionName . '"' . (in_array ( $optionName, $value ) ? 'checked' : '') . ' disabled><span class="FormCheck"><label for="form[' . $this->name . '][' . $optionName . ']">' . $option . '</label></span></input><br>';
$html .= '<input type="hidden" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" value="'.((in_array ( $optionName, $value )) ? $optionName : '').'">'; $html .= '<input type="hidden" id="form[' . $this->name . '][' . $optionName . ']" name="form[' . $this->name . '][]" value="'.((in_array ( $optionName, $value )) ? $optionName : '').'">';
} }
return $html; return $html;
@@ -4791,14 +4791,6 @@ class xmlformTemplate extends Smarty
if ($form->type == 'xmlform') { if ($form->type == 'xmlform') {
if ($v->type != 'checkgroup' && $v->type != 'radiogroup') { if ($v->type != 'checkgroup' && $v->type != 'radiogroup') {
$result[$k] = '<label for="form[' . $k . ']">' . $result[$k] . '</label>'; $result[$k] = '<label for="form[' . $k . ']">' . $result[$k] . '</label>';
} else {
if (is_array($v->options)) {
foreach ($v->options as $optionValue => $optionLabel) {
if (isset($form->fields[$k]->options[$optionValue])) {
$form->fields[$k]->options[$optionValue] = '<label for="form[' . $k . '][' . $optionValue . ']">' . $form->fields[$k]->options[$optionValue] . '</label>';
}
}
}
} }
} }
if (! is_array ( $value )) { if (! is_array ( $value )) {