Skip to content
Permalink
Browse files

Require Between Date Entries

This commit adds requirement for between dates. Also overrides default
InlineFormField error - not required for Advanced Search interface.
  • Loading branch information...
protich committed Nov 19, 2019
1 parent e3cc92a commit 1aaee586b42b91ec02ae4618d0bba8ee26a6e69d
Showing with 12 additions and 4 deletions.
  1. +12 −4 include/class.forms.php
@@ -2359,11 +2359,14 @@ function getSearchMethodWidgets() {
)),
'between' => array('InlineformField', array(
'form' => array(
'left' => new DatetimeField(),
'left' => new DatetimeField($config + array('required' => true)),
'text' => new FreeTextField(array(
'configuration' => array('content' => 'and'))
'configuration' => array('content' => __('and')))
),
'right' => new DatetimeField(),
'right' => new DatetimeField($config + array('required' => true)),
),
'configuration' => array(
'error' => '',
),
)),
'period' => array('ChoiceField', array(
@@ -2420,6 +2423,9 @@ function getSearchQ($method, $value, $name=false) {
case 'between':
$left = Format::parseDateTime($value['left']);
$right = Format::parseDateTime($value['right']);
if (!$left || !$right)
return null;
// TODO: allow time selection for between
$left = $left->setTime(00, 00, 00);
$right = $right->setTime(23, 59, 59);
@@ -3945,7 +3951,9 @@ class InlineFormField extends FormField {
function validateEntry($value) {
if (!$this->getInlineForm()->isValid()) {
$this->_errors[] = __('Correct any errors below and try again.');
$config = $this->getConfiguration();
$this->_errors[] = isset($config['error'])
? $config['error'] : __('Correct any errors below and try again.');
}
}

0 comments on commit 1aaee58

Please sign in to comment.
You can’t perform that action at this time.