Closed Joshuab1997 closed 3 years ago
When using autoconfiguration, don't set the parent:
app.form.flow.signupflow:
class: App\Form\SignupFlow
autoconfigure: true
I know that. I know if autoconfigure is true parent shouldn't be set. However, this error still shows up:
Service "app.form.flow.signupflow" not found: even though it exists in the app's container, the container inside "App\Controller\IndexController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.
Try using dependency injection instead : in your controller function add a SignupFlow $flow
and use the variable instead of getting the service id.
Hope this help
I tried doing that. As mentioned in the end, I'll get the following error:
Expected argument of type "int", but "NULL" given.
(it thinks the step number variable is null)
I'm not sure if this is because my flow isn't bound to an entity (which in my case isn't possible due to the use of an API). The entity the form is for indirectly isn't in the same project.
Yes you have to bind it to the entity in your database, this isnt an issue with the bundle anymore.
There's literally no way to get this working without?
I will say I am also using Symfony 4.4 and injection works for me.
/**
* @Route("/create", name="create_order")
* @param CreateOrderFlow $flow
* @return Response
*/
public function create(CreateOrderFlow $flow)
{
$formData = new Order();
// form of the current ste
$form = $flow->createForm();
....
I'm trying to implement this bundle in our project. We're currently using 4.4. I tried following the steps from the Github page however this doesn't seem to work.
The steps say you have to add the following to services.yaml for example:
app.form.flow.signupflow: class: App\Form\SignupFlow parent: craue.form.flow
I added this, but if I try to use
$flow = $this->get('app.form.flow.signupflow')
This will throw the following error:
Attribute "autowire" on service "app.form.flow.signupflow" cannot be inherited from "_defaults" when a "parent" is set. Move your child definitions to a separate file or define this attribute explicitly in C:\wamp64\www\test\multi-step-form\config/services.yaml (which is loaded in resource "C:\wamp64\www\test\multi-step-form\config/services.yaml").
I tried adding the autowire attribute (value is true), then I get the same error but for attribute autoconfigure. I put autoconfigure on false.
However, now the code throws the following error:
Service "app.form.flow.signupflow" not found: even though it exists in the app's container, the container inside "App\Controller\IndexController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services. Try using dependency injection instead.
I know in Symfony now you mostly use dependency injection. I've tried adding my flow class to the controller like this:
`public function index(SignupFlow $flow) { $form = $flow->createForm();
This will throw the following error:
Expected argument of type "int", but "NULL" given.
(this is on step number as the step number is null)
(as a note: I don't use an entity class with it as the data from the form should be passed to an API)