html - How to get default values on a form submitted via rest? -


I'm surprised that this is not already asked. I have a form on a web page that is being presented through a cool web service (this is actually using angular JS) the question is how should I set the default value on the form? (This clearly makes it an edit, I'm getting value from the server anyway)

An example
Let's say we have the checkbox on the form Opt-In / Out In Marketing Emails

  I would like to receive marketing email [x]  

In this case the default is to check the checkbox so that they will have to physically exit on the server In the old world of HTML creation, I will probably return these default to the professional level and then I will form the form html with the set.

Solution 1
Set the default value in the client as I am using angular, I can object to a JS that represents the default state of the form And uses it to start forming a form on it.

My problem with this approach is that it seems a bit wrong to put such business rules into the client.

Solution 2
Another option may be to hide the field which is the default value and only edit one of them. This may be fine for some kind of field, but for our optin area they definitely need to review it. This can be done when the fields were initially displayed without any lapse, then when you click a button to continue, the form is saved. The client can then simply get on the object and now displays all fields with all populated defaults.

I can not decide whether I like this view or not it is more than a request from the server, so in this regard it is not very efficient. Depending on which field is omitted, it can be presented in a strange way with some additional fields suddenly.

Solution 3
Finally we can create a rest Web service to get the default position. I have not seen any other examples of this so that no conventions are sure about it. Something like this:

 get  http: // server / rest / myresource / default  

Are there any such conventions? I miss Has anybody done this to himself and the way he works best got him?

Thanks

You are talking about an editing form, your Have some "default" (i.e. already saved data) and the data that is inserting the user. So you basically get data (via $ http) and use it for the extension of the form field (via angular.extend ). This is a bella which tells it better:


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -