Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to specify form attribute of each input when serializing? #335

Open
ngoonee opened this issue Feb 22, 2017 · 2 comments
Open

Possible to specify form attribute of each input when serializing? #335

ngoonee opened this issue Feb 22, 2017 · 2 comments

Comments

@ngoonee
Copy link

ngoonee commented Feb 22, 2017

I want to use DataTables for retail form rendering, one form per row, with different cells corresponding to different inputs.

As per http://stackoverflow.com/questions/5967564/form-inside-a-table forms are not allowed inside either <tbody> or <tr>, with the second answer indicating that setting the form attribute is a suitable workaround. However, I don't see any way to set that attribute with deform currently. It would make sense to be an argument to the serialize() function rather than being implemented per widget (just another attribute in the generated class).

For quick reference, a typical table row would look something like this (simplified)
<tr>
<td>
<form id='form1' class='form'>
<button type='submit' class='btn btn-default'>Submit</button>
</form>
<td>
<input name='input1' class='form-control' form='form1'>
</td>
<td>
<input name='input2' class='form-control' form='form1'>
</td>
</tr>

Currently I'm just calling a function which does a string replacement to insert the form='form1' line on the output of serialize, but something built-in to deform would be much preferred.

Have I missed something? Could this be added?

@ngoonee
Copy link
Author

ngoonee commented Feb 23, 2017

Currently I'm just calling a function which does a string replacement to insert the form='form1' line on the output of serialize, but something built-in to deform would be much preferred.

Not to mention that after some basic testing this doesn't work on datepicker type inputs. Somehow the order of elements is not reliable in request.POST, and this throws off the validator (obviously). Ref http://stackoverflow.com/questions/42406956/retail-rendered-deform-form-using-form-attribute-processing-of-date-is-unrel

@stevepiercy
Copy link
Member

You can have multiple forms in Deform. You need to make sure that all form fields have unique names. It may be better to put a form in each table cell, rather than each row. Personally I use datatables with links to edit individual records instead of editing records within the table.

Nonetheless I would gladly accept a PR with functional tests in deformdemo with your feature request.

@stevepiercy stevepiercy added this to the 3.1.0 milestone Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants