Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making dynamic forms (the best approach)

I have to develop an application for an Android Tablet. This will do the following:

I will connect to a web service to retrieve a dynamic list of forms. Those forms must be downloaded to fill them offline. When one or more forms are filled, and application is online, user can send them to a server clicked on a button.

Those forms will be dynamic. There isn't a predefined form. And they will have one or more pictures attached.

My problem is that I don't know how to do it.

I've thought:

  1. I could send a form as set of fields and their types. Once I download xml from web service, I will have to rebuild it to show it to user.

  2. Send an html page with a form.

  3. HTML5 (with PhoneGap).

  4. ...?

I think second option is the best. What do you think?

Once user has filled a form, how can I save its data? If I'm using a web page, I think I can save it as CSV.

First option will be an android native interface, so I could save it on SQLite or as txt file. How can I store those forms filled?

And then, when user comes back online, how can I send a txt file and image through a web service?

If you have another approach, you are welcome to share it.

like image 296
VansFannel Avatar asked Oct 09 '22 06:10

VansFannel


1 Answers

I would go for option 1 since it has a more native feel...

Fast brainstorm: You could create a DB with table: Forms (id, name ...), FormItems (id, formid, name, type, order ...), Data (id, FormItemsid, EntryId, value ...), Entries (id, dateadded, sent ...)

When you want to show a form you open an activity and you loop through all FormItems with that formid (you can have a LinearLayout (orientation: vertical) and addView for every item)

When you fill in a form a new Entry is created and you loop through your formitems and put the entred text in Data

When you go online you check what entries aren't sent yet and you send those items

Hope this was helpful!

like image 131
Ferdau Avatar answered Oct 12 '22 21:10

Ferdau