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

Pass parameter to form #264

Open
gmagnai opened this issue Aug 12, 2016 · 1 comment
Open

Pass parameter to form #264

gmagnai opened this issue Aug 12, 2016 · 1 comment

Comments

@gmagnai
Copy link

gmagnai commented Aug 12, 2016

Hello. I'm glad to using this builder.
Also i have to find some solutions about how to create edit form.

In that case i need to pass id to edit form.
I tried $this->getRequest()->id but it displays nothing.

Thank you. Sorry about my bad english.
Best regards.

@koenvu
Copy link
Contributor

koenvu commented Aug 12, 2016

If I understand correctly you want to pass the model you are editing to your form. Have you tried this:

$form = $this->form(YourFormClass::class, [
    'method' => 'PUT',
    'url' => '/someurl/'.$yourModel->id.'/edit',
    'model' => $yourModel,
]);

The model option is used to determine the 'default' values in your form. For example the firstname field will have a default value of $form->getModel()->firstname, where $form->getModel() is the model you passed in ($yourModel in my example).

Hope that helps!

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

No branches or pull requests

2 participants