Commit e7f864c5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow more characters in pieform 'checkboxes' labels (bug #905069)



The checkbox labels in the 'checkboxes' pieform element are shortened
to a hard-coded 17 characters.  This change lets the form
configuration specify some other number.

Change-Id: Ib225c7435b7ae2db03d59057485635c4de0d50e2
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent c2ec74c5
......@@ -46,6 +46,9 @@ function pieform_element_checkboxes(Pieform $form, $element) {/*{{{*/
$element['name'] .= '[]';
// Number of characters in checkbox labels (use 0 or false for no limit).
$labelwidth = isset($element['labelwidth']) ? (int) $element['labelwidth'] : 17;
foreach ($element['elements'] as $e) {
if (!$submitted || !empty($e['disabled'])) {
$checked = $e['defaultvalue'];
......@@ -53,11 +56,12 @@ function pieform_element_checkboxes(Pieform $form, $element) {/*{{{*/
else {
$checked = !empty($value[$e['value']]) || in_array($e['value'], $value);
}
$title = $labelwidth ? str_shorten_text($e['title'], $labelwidth, true) : $e['title'];
$result .= '<div class="checkboxes-option"><input type="checkbox" value="' . $e['value'] . '" '
. $form->element_attributes($element)
. ($checked ? ' checked="checked"' : '')
. (!empty($e['disabled']) ? ' disabled' : '')
. '>' . Pieform::hsc(str_shorten_text($e['title'], 17, true)) . '</div>';
. '>' . Pieform::hsc($title) . '</div>';
}
$result .= '<div class="cl"></div>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment