Using HTTP data
PeggyForms has a lot of HTTP/AJAX features. Whether you need data from a public webservice or validation logic from your own business logic, it is all possible. You can populate, validate, base logic and rules on HTTP requests and show information via HTTP requests.
Lets assume that we want a simple form with a dropdown populated by our webAPI. And we want to display some extra information about our selected item. Just add a dropdown field and an text/information field. First we setup the dropdown with dynamic content:
2. Your HTTP response object
Lets assume that your HTTP request will deliver this JSON result:
3. Using a property from your HTTP result object
Now you can access the property myProperty and use it in our textfield. Select your text/information field, go to the content tab and press the Select HTTP field button. In the dialog, choose your property and press Ok. That`s it. If you view your form you`ll see that this value will be replaced with the value in your HTTP response!
If your property is not in the list for some reason, choose 'other' and write a custom property, ie: myProperty.
If you use HTTP to populate a list or radio buttons, like in this example, you can also use the current dataset as source. If we want, for example, to display the body text in our html/info field, simply press the Select HTTP field button and choose one of the dataset properties, displayed like [*].body.
The [*]. tells Peggy Forms that we want to access the dataset. From there you can choose the path to your property. In our case, it is [*].body.