Skip to content

Commit a116418

Browse files
authored
Fix override of Searchbar/ValidatedTerm::DEFAULT_PATTERN (#357)
c014cf1 changed the value of the `DEFAULT_PATTERN` constant in `Searchbar/ValidatedTerm`, there is an override of this constant in `TermInput/ValidatedTerm`, which previously used the same value anyway. Since `Searchbar/ValidatedTerm::getPattern()` uses `self` to access the constant the override has no effect and entering invalid values in a `TermInput` no longer shows the expected error message. Using `static` should fix this problem.
2 parents 01b4082 + beed135 commit a116418

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Control/SearchBar/ValidatedTerm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract class ValidatedTerm
1313
*
1414
* @var string
1515
*/
16-
public const DEFAULT_PATTERN = '(?!\s*%s\s*$).*';
16+
public const DEFAULT_PATTERN = '^(?!\s*%s\s*$).*$';
1717

1818
/** @var string The search value */
1919
protected $searchValue;
@@ -162,7 +162,7 @@ public function getPattern(): ?string
162162
}
163163

164164
return $this->pattern ?? sprintf(
165-
self::DEFAULT_PATTERN,
165+
static::DEFAULT_PATTERN,
166166
static::escapeForHTMLPattern($this->getLabel() ?: $this->getSearchValue())
167167
);
168168
}

src/FormElement/TermInput/Term.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
interface Term
66
{
77
/** @var string The default validation constraint */
8-
public const DEFAULT_CONSTRAINT = '^\s*(?!%s\b).*\s*$';
8+
public const DEFAULT_CONSTRAINT = \ipl\Web\Control\SearchBar\ValidatedTerm::DEFAULT_PATTERN;
99

1010
/**
1111
* Set the search value

0 commit comments

Comments
 (0)