one-page-app-with-drupal-and-vue
one-page-app-with-drupal-and-vue copied to clipboard
Very nice tutorial
Great Vue.js tutorial, one of the best that really explains very well how to make SPA's with vue-router.
Maybe on question that arises from this tutorial. Is there a way to serialise a form with vue resorce without having to add models for each field? My SPA will have lot's of forms and creating data models for every field seems a bit lot of coding...? Or maybe somehow loop trough all the fields in the form and dynamically set up data model to send to server...
Hvala, Primoz
Not really sure Primož. Check out this fiddle maybe this is something you would want: http://jsfiddle.net/xb5h545w/1/
Hi Ivan. Yes that is something similar I want. I was brainstorming a little bit about this and I thought this might be good aproach:
- whenever accessing CREATE or UPDATE page for some resource I would request a list of fields for this resource from my API server. List of fields would include properties like: field name, default value, actual value (empty initially), validation rules, etc...
- Vuejs would then loop trough this list and build the form dynamically
- I would v-model the dynamically created fields to the actual value from above field list data
- Then use the vue-resource and send the field data back to the server
Do you think this might work ok?
This sounds like a great idea. But will it work? I really can't say - but it sounds very logical to me that something like this could be done.
@ivandoric I will make a prototype and let's see. Sound good strategy to decrease amount of code needed for creating forms on the front-end...
thank you for this, the tutorial is very well organized :)