Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Form] Camelize 'add' and 'remove' methods in the PropertyPath
This issue camelizes the 'add' and 'remove' methods,
as it is already done with the 'set' method.
This fixes a problem with properties like 'custom_messages',
where the 'add' and 'remove' methods are 'addCustom_message'
and 'removeCustom_message' instead of 'addCustomMessage'
and 'removeCustomMessage'.
  • Loading branch information
acasademont committed Jun 27, 2012
1 parent d0e1547 commit 9fabb3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Util/PropertyPath.php
Expand Up @@ -535,8 +535,8 @@ protected function camelize($string)
private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
{
if (null !== $singular) {
$addMethod = 'add' . ucfirst($singular);
$removeMethod = 'remove' . ucfirst($singular);
$addMethod = 'add' . $this->camelize($singular);
$removeMethod = 'remove' . $this->camelize($singular);

if (!$this->isAccessible($reflClass, $addMethod, 1)) {
throw new InvalidPropertyException(sprintf(
Expand All @@ -558,7 +558,7 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
}

// The plural form is the last element of the property path
$plural = ucfirst($this->elements[$this->length - 1]);
$plural = $this->camelize($this->elements[$this->length - 1]);

// Any of the two methods is required, but not yet known
$singulars = (array) FormUtil::singularify($plural);
Expand Down

0 comments on commit 9fabb3d

Please sign in to comment.