This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Daniel81
Daniel81

Hi,

Using the {{ form_open() }} syntax to create a form in a component, does anyone know how to bind a model to the form?

I've tried using {{ form_open({ model:'Path\To\Model' }) }} but with no success. I've looked at the Laravel Docs but can't seem to figure out how this would work using the Twig syntax.

As always, any help is much appreciated.

Last updated

axomat
axomat

Have a look at the user plugin where you find this line

{{ form_open({ request: 'onUpdate', model: member }) }}

This shows that you do not need to specify the path_to and you do not need quotes (although I am surprised about that!)

You should certainly have a request value otherwise it wont know which method to execute in the component.

Daniel81
Daniel81

@axomat

Thanks for that. I did try something similar but kept the quotes & capitalisation on the Model name - I will give it a try. I have the request on the form, just needed to figure out the model issue :)

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.