Framework7 Form Data
There are some form data methods which makes working with forms easy. See the two form data methods:
Form to JSON The formToJSON() method is used to convert all form fields values to JSON.
Form from JSON: The formFromJSON method is used to fill up form according to JSON data.
Form to JSON
Framework7 provides a method myApp.formToJSON(form) to convert all form field values to JSON.
myApp.formToJSON(form): This method accepts form as parameter which is a HTMLElement or string of form that must be converted to JSON. This parameter is required and this method returns JSON data.
Each input must have the name attribute, otherwise its value will not appear in JSON. Multiple selects and checkboxes will appear as arrays in JSON.
Let's take an example to demonstrate the use of form to JSON in Framework7:Test it Now
Form from JSON Example
Framework7 facilitates you to fill up the form according to JSON by using the following method:
myApp.formFromJSON(form, formData): This method accepts two parameters:
Let's take an example to demonstrate the use of form from JSON in Framework7:Test it Now
Next TopicFramework7 Form Storage