/*
* Two features in one function
* 1) return required parts
* If the attribute is required, return different required parts (attribute - html5, class - jquery, span - heading)
* 2) Initialize JQuery Check for required fields working with HTML 5
* Checkboxes cannot be checked by HTML 5, so we need help of jQuery which manage for example:
* There are 3 checkboxes - one selected, two not (It is OK but not for HTML5)
*/
public static function renderRequiredParts($id, $required)
{
// If the attribute is required
$req['attribute'] = '';
// Attribute - required field HTML 5
$req['span'] = '';
// Span - displayed * next to title
$req['class'] = '';
// Class - Checkboxes cannot be checked per HTML 5, jquery used PhocacartRenderJs::renderCheckBoxRequired()
$req['required'] = 0;
// data-required attribute
if ($required) {
$req['attribute'] = ' required="" aria-required="true"';
$req['span'] = ' <span class="ph-req">*</span>';
$req['class'] = ' checkbox-group-' . (int) $id . ' checkbox-group required';
$req['required'] = 1;
}
return $req;
}