formly
formly copied to clipboard
Using Formly with resources
It seems the modern way to open forms for resources is to use Form::model. Is there a corresponding function in Formly? If not, how do I set the action(s) when using Formly (preferably in a way that works for both creating new resources as well as editing existing ones)?
This is something that I am considering adding to Formly. Feel free to submit a pull request if you would like to help out.
At the moment, when setting actions, there are two options:
- Have different form views for updating and creating. Only the
$form->open()
needs to be different, you can load the rest of the form in a partial. - Do something like the following:
<?php if (isset($post->id) && $post->id > 0): ?>
<?php echo $form->openPut(route('posts.update', $post->id)); ?>
<?php else: ?>
<?php echo $form->open(route('posts.store')); ?>
<?php endif; ?>