Commit a256d4ad authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Fixed userlist and pieforms for 'required' rule

parent a13d0598
......@@ -47,9 +47,10 @@ $creategroup = pieform(array(
'cols' => 70,
),
'members' => array(
'type' => 'userlist',
'title' => get_string('groupmembers'),
'rules' => array( 'required' => true ),
'type' => 'userlist',
'title' => get_string('groupmembers'),
'rules' => array( 'required' => true ),
'filter' => false,
),
'submit' => array(
'type' => 'submitcancel',
......
......@@ -87,15 +87,15 @@ function pieform_element_userlist_get_value(Pieform $form, $element) {
return null;
}
function form_element_userlist_rule_required($value, $element) {
function pieform_element_userlist_rule_required(Pieform $form, $value, $element) {
if (is_array($value) && count($value)) {
return false;
return null;
}
return true;
return $form->i18n('rule', 'required', 'required', $element);
}
function form_element_userlist_set_attributes($element) {
function pieform_element_userlist_set_attributes($element) {
// By default, use the filter select box
if (!isset($element['filter'])) {
$element['filter'] = true;
......
......@@ -815,7 +815,7 @@ class Pieform {
if (!$this->get_error($element['name'])) {
// See if this element has a function that describes
// how this rule should apply to it
$function = 'pieform_element_' . $element['name'] . '_rule_' . $rule;
$function = 'pieform_element_' . $element['type'] . '_rule_' . $rule;
if (!function_exists($function)) {
// Try instead the default rule function
$function = 'pieform_rule_' . $rule;
......
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