how to pass $form->values from component?
- thcom
- Backer | 95
hi, can you please help me
i have form as component created with a factory
evertyhig work fine
but now i need to pass some parametr to redirect
something like
$this->redirect(‘Cities:seznam’, $form->values->parameter);
but how to access values ? when i use onSave[] function
thank you !
- Toanir
- Member | 57
Look into your CityForm class and wherever $this->onSave()
is
called, all of the parameters that are passed to the call can be used in the
callback in presenter. That means if there is somethign like
...
$formValues = ['gps' => 'here&there', 'name' => 'Kocourkov'];
$this->onSave($id, $formValues);
...
in your presenter you get to access that data by doing something like
$cityForm = $this->cityFormFactory->create( $this->currentCity);
$cityForm->onSave[] = function ($cityId, array $data) {
$this->alert("City $data[name] has been updated");
$this->redirect('Cities:detail', $cityId);
};
Take a note that only the order of parameter must match, their names are merely informative here
Last edited by Toanir (2020-03-02 09:15)
- Toanir
- Member | 57
Huh, I see. I didn't quite get what you meant by the part
In create: ...
and I thought your inquiries about the factory
wouldn't lead thcom to the solution quite as concisely.
I believe we are all talking about a form-wrapping component so I also tried to push thcom to examine the code “behind” the callbacks and make sense out of it for themselves.