The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
dropdown field passes text instead of value - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: dropdown field passes text instead of value (/showthread.php?tid=1617) |
dropdown field passes text instead of value - qedao - Sep 12th, 2011 Hello, This is my first post, I guess is something stupid, but I cannot find anything in the documentation about this: The problem is a dropdown field, when I see the submission in formtools, I got the dropdown text instead of the value: In the example, if I choose January, the form passes "January" as field content, when is supposed that it should pass the value, that is "1". Any ideas why this happens? I paste the field as it appears in the form following: <select size="1" name="Destination1_FromMonth"> <option value="0" selected>Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> RE: dropdown field passes text instead of value - qedao - Sep 12th, 2011 I reply to myself to add that: When I do the first submission to create the form, the sample data is passed properly (if I choose January, the form passes the value "1"). but after the form is registred, next submissions the text is passed and not the value. RE: dropdown field passes text instead of value - Ben - Sep 13th, 2011 Hi Qedao, Welcome to the forums! If I understand you correctly, that's just the way Form Tools works. It was designed to always show the text for dropdowns (i.e. "January", "February", etc.), but actually store the value (1, 2 etc) in the database. That's how HTML & forms are designed: to pass along one value (the value) but to give each one a user-friendly label. If you don't want to see the text, just edit the Option List and change the text for the dropdowns to have the same content as the values. Let me know if I misunderstood - Ben RE: dropdown field passes text instead of value - qedao - Sep 14th, 2011 Ben, thanks for your reply. You understood the problem right, and now I realize that Formtools is meant to behave this way, giving me the "text" while storing the "value" in the mysql. My problem is that Im using the email sent to import it into another database, so I need a smarty code that will provide the value instead of the text. Any chance on getting such code? I cannot find good smarty documentation anywhere. I guess I can also go ahead and change the text tags for the values I need but that seems less elegant :p Thanks for your help! is really apreciated RE: dropdown field passes text instead of value - Ben - Sep 14th, 2011 Hi Qedao, Interesting! Yes, changing the Option List does seem like a bit of a hack, doesn't it. Drat, I just checked out the code and no, the Option List value is never passed - only the display value - even in the advanced email templates. How may items are there in your Option List - just the 12, or are there other instances you're dealing with? If there aren't that many, you could add some logic to convert the strings back to the integer values... Code: {if $ANSWER_yourfield == "January"} Hack? Yup... ![]() - Ben RE: dropdown field passes text instead of value - qedao - Sep 14th, 2011 Ben, Thanks again, I only have this field to deal with. I guess that I will just change the text in the formtools list, after all is only me looking at it, so no one will complain for the inelegance of the solution. Thank you for the great job. Formtools is being a great help. |