Skip to content
This repository has been archived by the owner on Mar 17, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4 from lukesturgeon/master
Browse files Browse the repository at this point in the history
Added 'for' attribute to checkbox and radio button <label>s
  • Loading branch information
brandonkelly committed Jan 1, 2013
2 parents 731c014 + ddc0944 commit 1ffa5f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions ee2/third_party/pt_checkboxes/ft.pt_checkboxes.php
Expand Up @@ -76,9 +76,15 @@ function _display_field($data, $field_name)

foreach($this->settings['options'] as $option_name => $option_label)
{
$selected = in_array($option_name, $data) ? 1 : 0;
$r .= '<label>'
. form_checkbox($field_name.'[]', $option_name, $selected)
$field_data = array(
'name' => $field_name.'[]',
'id' => $option_name,
'value' => $option_name,
'checked' => in_array($option_name, $data) ? 1 : 0
);

$r .= '<label for="' . $field_data['id'] . '">'
. form_checkbox($field_data)
. NBS . $option_label
. '</label> ';
}
Expand Down
12 changes: 9 additions & 3 deletions ee2/third_party/pt_radio_buttons/ft.pt_radio_buttons.php
Expand Up @@ -66,9 +66,15 @@ function _display_field($data, $field_name)

foreach($this->settings['options'] as $option_name => $option)
{
$selected = ((string) $option_name === (string) $data);
$r .= '<label>'
. form_radio($field_name, $option_name, $selected)
$field_data = array(
'name' => $field_name,
'id' => $option_name,
'value' => $option_name,
'checked' => ((string) $option_name === (string) $data)
);

$r .= '<label for="' . $field_data['id'] . '">'
. form_radio($field_data)
. NBS . $option
. '</label>';
}
Expand Down

0 comments on commit 1ffa5f3

Please sign in to comment.