Fix HTML QuickForm compare fields parent compatibility function and HTML Markup in Grade models - Refs #8295

pull/2487/head
José Loguercio 9 years ago
parent c874509662
commit 6a3a53700d
  1. 6
      main/admin/grade_models.php
  2. 2
      main/inc/lib/formvalidator/Rule/CompareFields.php
  3. 11
      main/inc/lib/grade_model.lib.php

@ -48,6 +48,7 @@ function plusItem(item) {
document.getElementById("plus-"+(item+1)).style.display = "inline";
//document.getElementById("txta-"+(item)).value = "100";
//document.getElementById("txta-"+(item-1)).value = "";
$("input").removeClass("form-control");
}
}
@ -59,15 +60,17 @@ function minItem(item) {
document.getElementById("plus-"+item).style.display = "inline";
document.getElementById("min-"+(item-1)).style.display = "inline";
//document.getElementById("txta-"+(item-1)).value = "100";
$("input").removeClass("form-control");
}
if (item = 1) {
document.getElementById("min-"+(item)).style.display = "none";
$("input").removeClass("form-control");
}
}
</script>';
// The header.
Display::display_header($tool_name);
Display::display_header();
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_grade_models';
@ -168,4 +171,5 @@ switch ($action) {
$obj->display();
break;
}
echo '<script> $(document).ready(function(){ $("input").removeClass("form-control"); }); </script>';
Display :: display_footer();

@ -13,7 +13,7 @@ class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare
* @param string the value to compare
* @return boolean True if date is valid
*/
function validate($values, $operator_and_max_value) {
function validate($values = [], $operator_and_max_value = null) {
if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) {
$final_value = 0;
foreach ($values as $value) {

@ -106,8 +106,9 @@ class GradeModel extends Model
// Setting the defaults
$defaults = $this->get($id);
if ($defaults) {
$components = $this->get_components($defaults['id']);
}
if ($action == 'edit') {
if (!empty($components)) {
@ -143,21 +144,20 @@ class GradeModel extends Model
$template_title =
'&nbsp{element} <!-- BEGIN error --> <span class="form_error">{error}</span><!-- END error -->
<a href="javascript:plusItem(' . ($counter+1) . ')">
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="plus-' . ($counter+1) . '" src="'.Display::return_icon('add.png').'" alt="'.get_lang('Add').'" title="'.get_lang('Add').'">
'.Display::return_icon('add.png', get_lang('Add'), ['id' => 'plus-' . ($counter+1), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).'
</a>
<a href="javascript:minItem(' . ($counter) . ')">
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="min-' . $counter . '" src="'.Display::return_icon('delete.png').'" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'">
'.Display::return_icon('delete.png', get_lang('Delete'), ['id' => 'min-' . ($counter), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).'
</a>
</div></p></div>';
$renderer->setElementTemplate($template_title, 'components['.$i.'][title]');
$renderer->setElementTemplate($template_percentage, 'components['.$i.'][percentage]');
$renderer->setElementTemplate($template_acronym, 'components['.$i.'][acronym]');
if ($i == 0) {
$form->addRule('components['.$i.'][percentage]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addRule('components['.$i.'][percentage]', get_lang('OnlyNumbers'), 'numeric');
@ -187,7 +187,6 @@ class GradeModel extends Model
$counter++;
}
}
$form->setDefaults($defaults);
// Setting the rules

Loading…
Cancel
Save