I have these inputs in my twig file :
<input type="text" name="txtNom" id="txtNom" value="{{user.nom}}" />
<input type="text" name="txtPrenom" id="txtPrenom" value="{{user.prenom}}" />
<input type="radio" name="rbSexe" id="rbHomme" onclick="changeGender(this.id);" />
<input type="radio" name="rbSexe" id="rbFemme" onclick="changeGender(this.id);" />
So, for calling those inputs in my Controller, I use the name attribute, for the first two it's okay :
$utilisateur->setNom($request->get('txtNom'));
$utilisateur->setPrenom($request->get('txtPrenom'));
but those with radio type have the same name, so how can I call specific one of them?
$utilisateur->setSexe(?????????);
I solved the problem :
I give the inputs a value, and make the name looks like an array:
<input type="radio" name="rbSexe[]" value="Homme" id="rbHomme" onclick="changeGender(this.id);" />
<input type="radio" name="rbSexe[]" value="Femme" id="rbFemme" onclick="changeGender(this.id);" />
and for call it in Controller, I use this :
$s = $request->get('rbSexe',0)[0];
Related
Let's say I have this following HTML code -
<input type="text" placeholder="name" />
Which I want to convert to
<input type="{{type}}" placeholder="{{text}}" />
How can I do this using Handlebars.js?
I am trying to incorporate a reservation widget within my wordpress install and I have everything working fine except sending the data or it not populating on the other sites form. The site I am trying to send data to is an online reservation software: http://www.directinn.com/demo/
Here is how I am doing my form:
<form name="bookingform" action="http://www.directinn.com/demo" method="get" target="_blank">
<input type="text" name="date1" id="Text1" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Arrival Date"/>
<input type="text" name="date2" id="Text2" class="ftxt MyDate three columns" maxlength="10" value="" placeholder="Departure Date" />
<input type="submit" name="bookingformsubmit" class="book-now" value="Book Now">
<input type="hidden" name="arrivalDay" value="" />
<input type="hidden" name="arrivalMonth" value="" />
<input type="hidden" name="arrivalYear" value="" />
<input type="hidden" name="departureDay" value="" />
<input type="hidden" name="departureMonth" value="" />
<input type="hidden" name="departureYear" value="" />
<input type="hidden" name="numAdults" value="1" />
Any help would be greatly appreciated ;)
So they are saying if you can iFrame in their Form on your page and if you add the USERNAME for example to the URL, your USERNAME will appear on the invoice. Like this I believe:
http://www.directinn.com/iframefull.html/BOB
I do not think you can make your own form and POST to their page. I see no indication that that is possible from the link you posted of the example.
The code you have will submit a load of Query String data to the receiving site.
The target site may implement some type of cross-site posting prevention which is causing the blockage - or they may ignore your query string parameters entirely.
I'm using cmfformcontroller in an app to manage a list of entries.
Entries are displayed using :records as documented at http://pypi.python.org/pypi/zope.httpform
<form action=".">
<p>Please, enter information about one or more of your next of
kin.</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<input type="submit" />
</form>
I want my validator to be able to highlight a record using state.setError method. How could I achieve this ?
I have fix this use case by keeping a list of error key pattern: on starting by a pattern: id_field
I understand that if the all the inputs being entered as a, b, and c and all the checkbox are checked then the output would look like this.
response.write( request.form("a1") ) = a, b, c
response.write( request.form("chk") ) = 1, 1, 1
Is there a way to determined if the corresponding input text checkbox is checked if not all checkbox are checked?
ie: the input is being entered as a, b, and c then only the corresponding checkbox at "c" is checked.
The output of this will be:
response.write( request.form("a1") ) = a, b, c
response.write( request.form("chk") ) = 1
<form name="myForm">
<input type="text" name="a1" />
<input type="checkbox" name="chk" value="1" />
<input type="text" name="a1" />
<input type="checkbox" name="chk" value="1" />
<input type="text" name="a1" />
<input type="checkbox" name="chk" value="1" />
<input type"submit" value="submit" />
</form>
You're going to need to change the names of your inputs. The only type of input that is intended to have multiple instances sharing a name is a radio button. That is done so you can get the mutually-exclusive select behavior that radio buttons are designed for.
In this case, you're going to want to give each text and checkbox input a different name. So your HTML would look like:
<form name="myForm">
<input type="text" name="a1" />
<input type="checkbox" name="chk1" value="1" />
<input type="text" name="a2" />
<input type="checkbox" name="chk2" value="1" />
<input type="text" name="a3" />
<input type="checkbox" name="chk3" value="1" />
<input type"submit" value="submit" />
</form>
Then simply reference your third checkbox with:
response.write( request.form("chk3") )
It would require you to write a little code if you wanted the results to appear in a nice comma delimited list like you've shown, but I would argue that's appropriate.
If reason you want a comma-delimited string similar to "a, b, c" you could change the values of all your checkboxes to "1", "2", "3" instead of all being "1".
I have two radio buttons:
<input type="radio" name="group1" />1
<input type="radio" name="group1" />2
How do I know which one is selected when the form is posted?
The inputs should have values:
<input type="radio" name="group1" value="1" />1
<input type="radio" name="group1" value="2" />2
Then, the value will be posted on the name group1. On Asp.net you can get it using:
Request.Form["group1"]
If you are using runat="server", it can happen that name attribute is changed at client, so you will get null as value.