Adding form layout constants, horizontal or inline.

1.10.x
Julio Montoya 11 years ago
parent bdcde2739f
commit cfb1353e29
  1. 6
      main/attendance/attendance_sheet.php
  2. 33
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 2
      main/inc/lib/groupmanager.lib.php
  4. 11
      main/inc/lib/pear/HTML/QuickForm/select.php
  5. 4
      main/tracking/courseLog.php

@ -30,7 +30,8 @@ if (api_is_allowed_to_edit(null, true) ||
'post',
'index.php?action=attendance_sheet_list&' . api_get_cidreq() . $param_gradebook . '&attendance_id=' . $attendance_id,
null,
array('class' => 'form-search pull-left')
array(),
FormValidator::LAYOUT_INLINE
);
$values = array(
@ -57,7 +58,7 @@ if (api_is_allowed_to_edit(null, true) ||
}
$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
$form->addElement('style_submit_button', null, get_lang('Filter'), 'class="filter"');
$form->addButtonFilter(get_lang('Filter'));
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
@ -232,6 +233,7 @@ if (api_is_allowed_to_edit(null, true) ||
echo '<div class="divTableWithFloatingHeader attendance-calendar-table" style="margin:0px;padding:0px;float:left;width:55%;overflow:auto;overflow-y:hidden;">';
echo '<table class="tableWithFloatingHeader data_table" width="100%">';
echo '<thead>';
$result = null;
if (count($attendant_calendar) > 0 ) {
foreach ($attendant_calendar as $calendar) {
$date = $calendar['date'];

@ -2,10 +2,13 @@
/* For licensing terms, see /license.txt */
/**
* Objects of this class can be used to create/manipulate/validate user input.
* Class FormValidator
* create/manipulate/validate user input.
*/
class FormValidator extends HTML_QuickForm
{
const LAYOUT_HORIZONTAL = 'horizontal';
const LAYOUT_INLINE = 'inline';
public $with_progress_bar = false;
/**
@ -15,6 +18,7 @@ class FormValidator extends HTML_QuickForm
* @param string $action (optional Action (default is $PHP_SELF)
* @param string $target (optional Form's target defaults to '_self'
* @param mixed $attributes (optional) Extra attributes for <form> tag
* @param string $layout
* @param bool $trackSubmit (optional) Whether to track if the form was
* submitted by adding a special hidden field (default = true)
*/
@ -24,6 +28,7 @@ class FormValidator extends HTML_QuickForm
$action = '',
$target = '',
$attributes = null,
$layout = self::LAYOUT_HORIZONTAL,
$trackSubmit = true
) {
// Default form class.
@ -31,6 +36,19 @@ class FormValidator extends HTML_QuickForm
$attributes['class'] = 'form-horizontal';
}
if (isset($attributes['class']) && strpos($attributes['class'], 'form-search') !== false) {
$layout = 'inline';
}
switch ($layout) {
case self::LAYOUT_HORIZONTAL:
$attributes['class'] = 'form-horizontal';
break;
case self::LAYOUT_INLINE:
$attributes['class'] = 'form-inline';
break;
}
parent::__construct($name, $method, $action, $target, $attributes, $trackSubmit);
// Load some custom elements and rules
@ -298,7 +316,7 @@ EOT;
}
/**
* Shortcut to import button
* Shortcut to export button
* @param string $label
*/
public function addButtonExport($label, $name = 'submit')
@ -306,6 +324,17 @@ EOT;
return $this->addButton($name, $label, 'check', 'primary');
}
/**
* Shortcut to filter button
* @param string $label
*/
public function addButtonFilter($label, $name = 'submit')
{
return $this->addButton($name, $label, 'filter', 'primary');
}
/**
* @param string $name
* @param string $label

@ -2692,7 +2692,7 @@ class GroupManager
public static function getSearchForm()
{
$url = api_get_path(WEB_CODE_PATH).'group/group_overview.php?'.api_get_cidreq();
$form = new FormValidator('search_groups', 'get', $url, null, array('class' => 'form-search'));
$form = new FormValidator('search_groups', 'get', $url, null, array(), FormValidator::LAYOUT_INLINE);
$form->addElement('text', 'keyword');
$form->addElement('button', 'submit', get_lang('Search'));
return $form->toHtml();

@ -72,8 +72,15 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
* @access public
* @return void
*/
function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null)
{
public function HTML_QuickForm_select(
$elementName = null,
$elementLabel = null,
$options = null,
$attributes = null
) {
if (is_array($attributes) || empty($attributes)) {
$attributes['class'] = 'form-control';
}
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'select';

@ -259,8 +259,8 @@ $form_search = new FormValidator(
'GET',
api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq(),
'',
array('class' => 'form-search'),
false
array(),
FormValidator::LAYOUT_INLINE
);
$renderer = $form_search->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span>');

Loading…
Cancel
Save