+1 I've been waiting for this as well. I have an entire back end I'm waiting to code up until I learn how to do this.
Dynamic Forms
Howdy,
Does anyone know if any of the Laracasts lessons cover how to plan and create dynamic forms in Laravel? For example if you have an admin area for an app, and on a edit form for a specific page you want to allow the admin to add another field to the form to enter additional data.
I'd imagine it's an advanced topic, but was wondering if any of the lessons mention something related to this or if anyone knows of a good resource to learn how to plan and allow for such a feature.
Any help would be appreciated, thanks!
You could use a Command bus also covered widely here on Laracasts or you could use a Service class, You've should know the fields available on the model (table), you've properly already defined those fields in the $fillable property on you model.
You could therefore setup a class or method to filter all input and sort out which are not listed on the model, and send them off to the fields table.
Alternatively you could wrap you custom fields in an array in the frontend like:
<input type="text" name="[custom][]" value=""/>
Now you know when you parse the Input::all() that custom contains all of the fields that should be added to the fields.
Hope it makes sense?
I would properly go with the last approach..
Please or to participate in this conversation.