0

I changed, by client requirement, an entity textfield (weekly_exercise) to a 1:n relation. Everything works normally so far, but when trying to save the form Symfony looks out for a "changed" method name.

That's the error message I get

Neither the property "weekly_exercise" nor one of the methods "addWooklyExercise()"/"removeWooklyExercise()", "setWeeklyExercise()", "weeklyExercise()", "__set()" or "__call()" exist and have public access in class "XXX\CourseBundle\Entity\Course".

Of course "addWooklyExercise()"/"removeWooklyExercise()" don't exist. I could put them in and proxy to the real methods, but that would only be an ugly hack.

I've been looking through all my files and couldn't find a anything that could be responsible for this issue.

I'm on Symfony 2.5.7 as my client doesn't allow me to update!!

Files involved in the issue https://gist.github.com/mhauptma73

EDIT:

For some reason the method

public function addWooklyExercise(\BDA\CourseBundle\Entity\CourseWeeklyExercise $weeklyExercise)
{

    $this->__initializer__ && $this->__initializer__->__invoke($this, 'addWooklyExercise', array($weeklyExercise));

    return parent::addWooklyExercise($weeklyExercise);
}

is being added in the cache proxy. But there is also the correctly spelled method, before the misspelled one.

Michi
  • 2,480
  • 3
  • 28
  • 38

2 Answers2

0

That looks like you have a typo somewhere, probably your Entity, your Form-Type or when outputting a form in a template. Try doing a search over the whole src/ directory for wookly and you will probably find it.

dbrumann
  • 16,803
  • 2
  • 42
  • 58
  • Did you check in the templates as well? Did you have case matching enabled, i.e. did you also check for Wookly or WOOKLY? – dbrumann Apr 16 '17 at 08:22
  • I disabled case mathing to be sure and looked through both php and twig files.I also checked the POST parameters that are being sent and they look the way they should. – Michi Apr 16 '17 at 08:37
  • In your entity you could temporarily create the getter and setter for wooklyExcercise and then try to find the usages. It's a long shot, but maybe that will bring up the wrong access – dbrumann Apr 16 '17 at 08:40
  • That worked... but how to I get now to know where the real problem occurs? – Michi Apr 16 '17 at 08:46
  • PhpStorm has a Find Usage function in the dropdown menu when you right click on the function name: http://imgur.com/a/b0AjH – dbrumann Apr 16 '17 at 08:58
  • I'm downloading phpstorm in case it can help me :-) – Michi Apr 16 '17 at 09:02
  • No Usages found :-( – Michi Apr 16 '17 at 09:30
0

Follow the naming convention like when you add the property for oneToMany then it's plural and for add or remove method change it to singular.

protected $tags;

public function addTag(Tag $tag)
{
    //...
}

public function removeTag(Tag $tag)
{
    // ...
}

See more details read this doc: http://symfony.com/doc/2.7/form/form_collections.html#form-collections-new-prototype

habibun
  • 1,552
  • 2
  • 14
  • 29
  • Might be a good idea convention-wise, but it won't solve my issue as the parameters are send correctly. Am I wrong? – Michi Apr 17 '17 at 09:04
  • I finally opted to change the naming and implemented it convention-wise. whether it was changing the name or the convetion, but the issue went away :-) – Michi May 10 '17 at 08:37