Commit 568ca6c4 authored by Nigel McNie's avatar Nigel McNie Committed by Penny Leach
Browse files

Added support in pieforms for 'requiredmarker', to add *'s to required fields

parent b01bc6a0
......@@ -78,6 +78,9 @@ function pieform_renderer_maharatable(Pieform $form, $builtelement, $rawelement)
else {
$result .= '<label for="' . $formname . '_' . $rawelement['id'] . '">' . Pieform::hsc($rawelement['title']) . '</label>';
}
if ($form->get_property('requiredmarker') && !empty($rawelement['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
$result .= "</th>\n\t</tr>\n";
}
$result .= "\t<tr id=\"{$formname}_{$rawelement['name']}_container\">\n\t\t<td>";
......
......@@ -288,7 +288,10 @@ class Pieform {
'tabindex' => false,
// Whether to add a class of the type of the element to each element
'elementclasses' => false
'elementclasses' => false,
// Whether to add * markers after each required field
'requiredmarker' => false,
);
$data = array_merge($formdefaults, $formconfig, $data);
$this->data = $data;
......
......@@ -54,6 +54,9 @@ function pieform_renderer_div(Pieform $form, $builtelement, $rawelement) {
else {
$result .= '<label for="' . $formname . '_' . $rawelement['id'] . '">' . Pieform::hsc($rawelement['title']) . '</label>';
}
if ($form->get_property('requiredmarker') && !empty($rawelement['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
}
$result .= $builtelement;
......
......@@ -139,6 +139,9 @@ class FormRendererMultiColumnTable {
if (isset($data['settings']['title'])) {
$result .= Pieform::hsc($data['settings']['title']);
}
if ($form->get_property('requiredmarker') && !empty($rawelement['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
$result .= "</th>\n\t";
foreach ($data['builtelements'] as $k => $builtelement) {
......
......@@ -62,6 +62,9 @@ function pieform_renderer_oneline(Pieform $form, $builtelement, $rawelement) {
else {
$result .= '<label for="' . $rawelement['id'] . '">' . Pieform::hsc($rawelement['title']) . '</label>';
}
if ($form->get_property('requiredmarker') && !empty($rawelement['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
}
$result .= $builtelement;
......
......@@ -77,6 +77,9 @@ function pieform_renderer_table(Pieform $form, $builtelement, $rawelement) {
else {
$result .= '<label for="' . $formname . '_' . $rawelement['id'] . '">' . Pieform::hsc($rawelement['title']) . '</label>';
}
if ($form->get_property('requiredmarker') && !empty($rawelement['rules']['required'])) {
$result .= ' <span class="requiredmarker">*</span>';
}
}
$result .= "</th>\n\t\t<td>";
$result .= $builtelement;
......
Supports Markdown
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