Skip to content

Commit 5c8095a

Browse files
author
ndm2
committed
Exclude ._ids postfixed fieldnames from pluralization
As per convention, fieldnames for belongsToMany associations should be expected to be already in plural form.
1 parent 188862b commit 5c8095a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/View/Helper/FormHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,14 +1170,17 @@ protected function _optionsOptions($fieldName, $options)
11701170
return $options;
11711171
}
11721172

1173+
$pluralize = true;
11731174
if (substr($fieldName, -5) === '._ids') {
11741175
$fieldName = substr($fieldName, 0, -5);
1176+
$pluralize = false;
11751177
} elseif (substr($fieldName, -3) === '_id') {
11761178
$fieldName = substr($fieldName, 0, -3);
11771179
}
11781180
$fieldName = array_slice(explode('.', $fieldName), -1)[0];
1181+
11791182
$varName = Inflector::variable(
1180-
Inflector::pluralize($fieldName)
1183+
$pluralize ? Inflector::pluralize($fieldName) : $fieldName
11811184
);
11821185
$varOptions = $this->_View->get($varName);
11831186
if (!is_array($varOptions) && !($varOptions instanceof Traversable)) {

0 commit comments

Comments
 (0)