Reputation: 4316
Let's admin I have an entity RestaurantOrder
with a property status
status
can take these values
new
accepted
being prepared
delivered
cancelled by customer
cancelled by kitchen
etc.
Now what I want is that in the backend when I edit one Restaurant order, that the list of status
presented to me is dependent of the current status
the simplest I've found would for my entity to have a method getPossibleStatusChange
which return an array of the possible choices (using the complex rules given by the business requirements)
But I haven't found in Symfony2 for Choices an option to say "call method from current entity"
I know already how to populate a choices from a static callback or from a callback that call the Repository
Is there such an option?
Upvotes: 0
Views: 375
Reputation: 2633
I do not know of a possibility for that.
You can access the unterlying object in the formType though:
$builder->getForm()->getData();
You can work on that to use your method, to generate your choices.
Upvotes: 1