Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed hasTag function due to Error in Symfony 4.3.* #19

Closed
wants to merge 6 commits into from
Closed

Removed hasTag function due to Error in Symfony 4.3.* #19

wants to merge 6 commits into from

Conversation

DevNico
Copy link

@DevNico DevNico commented Jun 17, 2019

When using Symfony 4.3.* the "hasTag" function causes the Error: Property "tag" does not exist in class "App\Entity\SomeEntity". Therefore I propose removing it.

This is my first PR so any feedback regarding my description or anything else would be greatly appreciated!

@garak
Copy link
Member

garak commented Jun 18, 2019

I appreciate your effort.
But, before opening a PR, you should open an issue describing the supposed error. Maybe there's a simpler solution, not involving the change of an interface (that's a BC break)

@DevNico
Copy link
Author

DevNico commented Jun 18, 2019

Okay noted for next time. Do you have any idea on how to solve this without changing the interface?

@garak
Copy link
Member

garak commented Jun 18, 2019

You should provide a way to reproduce your error

@DevNico
Copy link
Author

DevNico commented Jun 18, 2019

Php Version: 7.3.6 via homebrew on macOS Mojave 10.14.5

Steps to reproduce:

  • composer create-project symfony/website-skeleton my-project && cd my-project
  • composer require symfony/orm-pack
  • composer require --dev symfony/maker-bundle
  • composer require symfony/form
  • composer require beelab/tag-bundle
  • php bin/console make:entity (Create a test entity)
  • Make it extend AbstractTaggable and add fields as shown in the documentation
  • php bin/console make:crud (For the test entity)
  • symfony serve (Go to: https://localhost:8000/test/entity/new, or what ever the link to your entity create page is)
    => First error: $tags needs to be protected instead of private (Docs error)
    => Second error after changing to protected: Property "tag" does not exist in class "App\Entity\TestEntity"

Example repository: https://github.com/DevNico/Tagbundle-Error-Demo

@garak
Copy link
Member

garak commented Jun 18, 2019

Well done (except for missing .env in repo).
So, you're trying to use a form bound to an entity, but unfortunately the fields you defined in form don't match properties in your entity.
I suggest you to re-read (I'm sure you already read it once) documentation about Symfony forms

@garak garak closed this Jun 18, 2019
@DevNico
Copy link
Author

DevNico commented Jun 18, 2019

I'm sorry but I don't think that's the case. In the TestEntityType buildForm function the only fields I add are: name, updated and tagsText. Those all exist and match my entity! I think the problem still is that Symfony sees the HasTag Method and then proceeds to look for a tag property - why? I don't know. If I didn't get something could you please clarify again?

@garak
Copy link
Member

garak commented Jun 18, 2019

I see you changed your form.
Still, fields in your form don't match properties in your entity

@DevNico
Copy link
Author

DevNico commented Jun 18, 2019

I'm sorry but I don't get what you mean by that. Could you elaborate that a bit more?

@garak
Copy link
Member

garak commented Jun 18, 2019

Try this:

  • fix class reference in src/Form/TestEntityType.php
  • remove updated field in src/Form/TestEntityType.php
  • comment out last 2 lines in config/packages/validator.yaml and provide your own validation

@DevNico
Copy link
Author

DevNico commented Jun 18, 2019

Thanks a lot! I got it to work. Next time I will just write an issue. The only thing you might want to change is the part of the documentation where $tags is private to protected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants