Skip to content

Commit e3af681

Browse files
committed
Removed interface method in favor of annotation for BC
1 parent 6e2e6d2 commit e3af681

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/View/Form/ContextInterface.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
/**
1818
* Interface for FormHelper context implementations.
19+
*
20+
* @method string getRequiredMessage($field) Gets the default "required" error message for a field
1921
*/
2022
interface ContextInterface
2123
{
@@ -70,14 +72,6 @@ public function val($field);
7072
*/
7173
public function isRequired($field);
7274

73-
/**
74-
* Gets the default "required" error message for a field
75-
*
76-
* @param string $field A dot separated path to the field
77-
* @return string
78-
*/
79-
public function getRequiredMessage($field);
80-
8175
/**
8276
* Get the fieldnames of the top level object in this context.
8377
*

src/View/Helper/FormHelper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,11 +1435,13 @@ protected function _magicOptions($fieldName, $options, $allowOverride)
14351435
$options['required'] = $context->isRequired($fieldName);
14361436
}
14371437

1438-
$message = $context->getRequiredMessage($fieldName);
1439-
if ($options['required'] && $message && $this->getConfig('useValidationMessages')) {
1440-
$message = h(addslashes($message));
1441-
$options['oninvalid'] = "this.setCustomValidity('$message')";
1442-
$options['onvalid'] = "this.setCustomValidity('')";
1438+
if (method_exists($context, 'getRequiredMessage')) {
1439+
$message = $context->getRequiredMessage($fieldName);
1440+
if ($options['required'] && $message && $this->getConfig('useValidationMessages')) {
1441+
$message = h(addslashes($message));
1442+
$options['oninvalid'] = "this.setCustomValidity('$message')";
1443+
$options['onvalid'] = "this.setCustomValidity('')";
1444+
}
14431445
}
14441446

14451447
$type = $context->type($fieldName);

0 commit comments

Comments
 (0)