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

Set form options #312

Open
louis-l opened this issue Feb 3, 2017 · 2 comments
Open

Set form options #312

louis-l opened this issue Feb 3, 2017 · 2 comments

Comments

@louis-l
Copy link

louis-l commented Feb 3, 2017

Hi,

Im not sure im using it wrong or not, I want to dynamically set form model if the request input is defined.

Here is my code:

// Create the form
$form = $formBuilder->create(MyForm::class)
    ->setUrl('...')
    ->setMethod('POST')
    ->setFormOptions(['model' => $model])
    ->remove('...');

But the $this->getModel() returns empty.

Then I change to:

$form = $formBuilder->create(MyForm::class, [
    'url' => '...',
    'method' => '...',
    'model' => $model,
])->remove('submit.update');

And it works properly.

Am I doing anything wrong?

@kristijanhusak
Copy link
Owner

you should use setFormOptions(['model' => $model]) instead of setupFieldOptions.

@louis-l
Copy link
Author

louis-l commented Feb 3, 2017

Sorry that was a typo, I meant setFormOptions

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