Storing data in collection forms in Symfony2 - javascript

Why do they store HTML tags with values in data-prototype instead of storing it just as values?
This leads to big amount of duplicated data.

data-prototype attribute hold the html of collection item. You can get this html, insert in form and you get new collection item. You can`t store it as real html in form cause it would be sended to server spite of the fact that this field can be invisible. You can put it iutside the form using render tag and access later using js.

Related

How to edit and save a reactive form in Angular 2?

I have built a reactive form, and persisting the data, at initial step I would be saving the form with initial set of data.
for eg:- I have an array of objects as below :
[{Name:'Tom',age:'25',subject:'maths'}].
On saving this to DB, I will be getting a unique ID, Say Student ID.. By using this ID I would need to edit the Data..
Could you please help me how I should be editing the data and save back
P.S., I have a data service where I will be temporarily storing the data and getting the data.

Populating form components from database using innerHTML

I need to populate form components(either select,checkbox) from database. The fields of the form depend on each other, i.e I need to populate a component based on user selection on the previous component. To do that, I am using onchange method, from which I raise a AJAX request for the data that need to populate the next tag. Right now, I am returning the string(HTML data) from the controller in backend and setting the corresponding id's innerHTML to these string. I am curious, whether the approach is correct way or should I take the json as the output from AJAX call and generate the HTML in js and then set the innerHTML value to the corresponding id. I am using JSP as View.
i think building the json and building up the components in the page side is safer becuse it makes your business login separate from the view. If it is required to construct a dynamic table without a POJO then there is no other go you have to use the html string data as the output of ajax

Javascript dynamic list POST/GET interaction design

This is a design question.
I have a dynamically changing list that works by creating DOM elements and populating them with the fields and these list elements can be added and removed. However, I'm not sure how to design the interaction with the backend server through POST/GET requests. If it helps, I'm using mongoDB and python flask.
My problem is that I'm not sure how to, given an list element (a div container as a list element), retrieve sufficient information about said list element to complete the POST/GET requests.
Should I attach additional fields to the div element itself that holds data like name, description, timestamp? Or should I have a JSON object that keeps track of each list element by id (or something) and it's associated identification data? Or should I be doing something else altogether?
As a side node, where can I turn to learn these design/stylistic things? Thanks!
That's what forms are for.
<form name="form1" action="index.htm" method="GET">
(put fields here)
<input type="submit" value="Submit"></input>
</form>
Change index.htm to the name of the page. Put any fields you want to pass to a POST/GET request in there. Any input fields with a name attribute should have their value passed. Change GET to POST if that's what you prefer. Then you must use a server side language like PHP to interpret the sent data.

Front end form submission

I've been looking around and haven't been able to find an answer to this.
I have a form that has to be submitted and the data to be processed entirely on the front end(in javascript). Is there a way that I can pass the form data to an action page and not to the same page. Right now I'm just emptying all data in the section and replacing it with the data that is being called; but I would like to do this similar to how a form would interact with php or python.
Thank you
-Art
What you could do is use HTML5 local or session storage to store all of the form values that a user enters and then on the new page use the stored values as you require.
http://diveintohtml5.info/storage.html

Sending parameters with the autogenerated post submit/create button in MVC 3 razor

I read online about how to send a variable from javascript with ajax but I am not sure that solution fit my needs.
What I am trying to do is this:
I have an automated form for creating a row at my DB.
What I Want to do is run a javascript code that will create a variable with logic based on the user input and than send this variable along with all the other fields that are automatically being sent because of the automated creation and binding of the model.
Basically what I want is to add another array to the automated post call that I didn't wrote because it is being generated automatically by mvc. and than I can retrieve this variable (array at my case) at the create method on the controller
Do you have a solution for this?
Thank you very much
You could add some hidden fields to the form and use Javascript to fill their values in the submit event.

Categories

Resources