Skip to content

Update entity.rst #18905

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

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reference/forms/types/entity.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Using a Custom Query for the Entities

If you want to create a custom query to use when fetching the entities
(e.g. you only want to return some entities, or need to order them), use
the `query_builder`_ option::
the `query_builder`_ option. Please note, that `query_builder` is used to compose data, not fetch real final results::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this change. In the description of the query_builder option we have this:

The value of this option can either be a QueryBuilder object, a callable or null (which will load all entities). When using a callable, you will be passed the EntityRepository of the entity as the only argument and should return a QueryBuilder. Returning null in the Closure will result in loading all entities.

Maybe change this line to something like this:

Suggested change
the `query_builder`_ option. Please note, that `query_builder` is used to compose data, not fetch real final results::
the `query_builder`_ option (which must be a `QueryBuilder` object, a closure returning a `QueryBuilder` object or `null` to load all entities)::

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like a lot this proposal. @toci-to-ci do you like it too? If this is more clear for you now, we can merge this suggestion. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz There is a lot of questions (stackoverflow ie) WHY error apears when using 'query_builder', PPL are using EntityType in Form same as Repository and fetch data which generate error message. The sugestion of @xabbuch is OK, it is mentioned earlier in documentation how field can act,

I just want to point out, that 'query_builder' is different way to extract (prepare) data than typical EntityRepository

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now merged. While merging it I reworded as suggested by @xabbuh.


use App\Entity\User;
use Doctrine\ORM\EntityRepository;
Expand Down