FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with submitting values multiple select
#1
Hi all,

After weeks of tailoring quiet a complex form with about 92 validation rules I discovered that values chosen from a multiple select box are not submitted to the views within form tools.

The multiple values chosen from multiple selectbox B are preceded by a choice from a select box A (not multiple) that generates a list in checkbox B. (hope I formulated this clearly)

Somewhere in the documentation Ben mentiones that for checkboxes or multiple select boxes the field names must contain '[]' . I have searched and searched and could not find an answer in the documentation.

Has anyone encountered the same problem?

I would be glad to have some advice.

Thanks in advance!

Bert
Reply
#2
Hi Bert,

Yes, that's exactly it: PHP requires you to enter [] characters at the end of the name attribute value in order to let the server know to expect multiple values. e.g.

Code:
<select name="myfield[]" multiple size="5"> ... </select>

But within Form Tools, the form name field should just be "myfield" (no square brackets).

This is again an odd PHP-ism.

So you've tried this without any luck?

- Ben
Reply
#3
(Mar 28th, 2010, 4:20 PM)Ben Wrote: Hi Bert,

Yes, that's exactly it: PHP requires you to enter [] characters at the end of the name attribute value in order to let the server know to expect multiple values. e.g.

Code:
<select name="myfield[]" multiple size="5"> ... </select>

But within Form Tools, the form name field should just be "myfield" (no square brackets).

This is again an odd PHP-ism.

So you've tried this without any luck?

- Ben

Hi Ben,

Thanks for your always so quick answer. I really like the way you treat messages in general....a compliment!

However...(as you might expect...;-).

First of all I do not use PHP (yet) in the form I mentioned. I do not (yet) make use of the Form Tools API. I only use HTML and rsv.js. Part of the rules (of in total 197 rules!) I apply follows below:

rules.push("required,date1,vul de datum in.");
rules.push("required,mw,hoe heet je?");
rules.push("required,pr_AZ,projectnaam goed invullen.");
rules.push("required,wrks_cat1,kies een werksoort.");

pr_AZ is a select box where users can pick a letter from the alfabet.
This triggers a javascript that via an array produces a list in a field 'pr_naam' : a multiple select box where users can select more values (with Ctrl) starting with the letter (A-Z) from 'pr_AZ'.

Problem is that those values do not appear within form tools.

Now:

1. where exactly do I make sure the field value has [] brackets?
2. in the rule? in the form field name? and how am I sure that within form tools the right field value(s) appear(s)?
3. Could the javascript used to automatically trigger the list in 'pr_naam' be the cause of the problem?

In the body part the code goes:

<select name="pr_AZ" id="pr_AZ" onChange="pr_AZ_OnChange()" class="selectAZ"><option value=""></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option><option value="E">E</option><option value="F">F</option><option value="G">G</option><option value="H">H</option><option value="I">I</option><option value="J">J</option><option value="K">K</option><option value="L">L</option><option value="M">M</option><option value="N">N</option><option value="O">O</option><option value="P">P</option><option value="Q">Q</option><option value="R">R</option><option value="S">S</option><option value="T">T</option><option value="U">U</option><option value="V">V</option><option value="W">W</option><option value="X">X</option><option value="Y">Y</option><option value="Z">Z</option></select>
<select id="pr_naam" name="pr_naam" class="selectmultiple"><option value=""></option></select></li>



I hope to have provided you with enough information to go on.

Thanks again in advance!


Bert.

I retried the form submission using brackets and now it produces (,,) as values....
Reply
#4
I think the problem lies in the fact that the javascript mentioned produces the list and therefore is not 'seen' by formtools. Would it help to manually add form field values (as the form field select box pr_naam contains no values) ?

Thanks again!
(Mar 29th, 2010, 1:29 AM)bvdveen Wrote: I think the problem lies in the fact that the javascript mentioned produces the list and therefore is not 'seen' by formtools. Would it help to manually add form field values (as the form field select box pr_naam contains no values) ?

Thanks again!

I tested the form with formtools 1,51 and had no problems....
Reply
#5
Hey Bert,

Sorry for the wait!

Quote:1. where exactly do I make sure the field value has [] brackets?

Even if your page is just HTML, any multi-select fields will need to have those brackets at the end of the select box's name attribute. So, your HTML would look like this:

Code:
<select id="pr_naam" name="pr_naam[]" class="selectmultiple"><option value=""></option></select>

But also, I'm pretty sure you'll need to add a "multiple" attribute to allow the users to be able to select multiple items, so try this:

Code:
<select id="pr_naam" name="pr_naam[]" class="selectmultiple" multiple><option value=""></option></select>

Quote:2. in the rule? in the form field name? and how am I sure that within form tools the right field value(s) appear(s)?

I'm not quite following you here... but in terms of seeing the info in Form Tools, I'd suggest doing this: temporarily change the field type for the "pr_naam" within Form Tools to a textarea field. That'll be easiest to see what values are actually being stored by Form Tools for each form submission. Once it's been ascertained that it is indeed storing multiple values (separated by a ", "), you can go back and change it back to a multi-select field with the appropriate dropdown values.

Quote:3. Could the javascript used to automatically trigger the list in 'pr_naam' be the cause of the problem?

I really do think it's just a configuration problem in the form - Form Tools doesn't care HOW the form is actually created. You could use JS to construct the entire form - form element included! - as long as it receives a POST request, it's happy.

If you like, post me back with a link to the form and I could take a look to confirm the form looks okay.

- Ben
Reply
#6
(Apr 3rd, 2010, 4:23 PM)Ben Wrote: Hey Bert,

Sorry for the wait!

Quote:1. where exactly do I make sure the field value has [] brackets?

Even if your page is just HTML, any multi-select fields will need to have those brackets at the end of the select box's name attribute. So, your HTML would look like this:

Code:
<select id="pr_naam" name="pr_naam[]" class="selectmultiple"><option value=""></option></select>

But also, I'm pretty sure you'll need to add a "multiple" attribute to allow the users to be able to select multiple items, so try this:

Code:
<select id="pr_naam" name="pr_naam[]" class="selectmultiple" multiple><option value=""></option></select>

Quote:2. in the rule? in the form field name? and how am I sure that within form tools the right field value(s) appear(s)?

I'm not quite following you here... but in terms of seeing the info in Form Tools, I'd suggest doing this: temporarily change the field type for the "pr_naam" within Form Tools to a textarea field. That'll be easiest to see what values are actually being stored by Form Tools for each form submission. Once it's been ascertained that it is indeed storing multiple values (separated by a ", "), you can go back and change it back to a multi-select field with the appropriate dropdown values.

Quote:3. Could the javascript used to automatically trigger the list in 'pr_naam' be the cause of the problem?

I really do think it's just a configuration problem in the form - Form Tools doesn't care HOW the form is actually created. You could use JS to construct the entire form - form element included! - as long as it receives a POST request, it's happy.

If you like, post me back with a link to the form and I could take a look to confirm the form looks okay.

- Ben

Hi Ben,

I hope you had a nice Easter weekend!

As to my form...I hace tried all the possibilities you mentioned. Probably oversaw a small item!
Actually the problem lies in the names wrks_naam1[] and wkrs_naam2[]..

Thanks again for your reply!

Greetings

Bert

I will inculde a link to the form, as it is to big to post here I guess...


Attached Files
.txt   bvdvform.txt (Size: 58.74 KB / Downloads: 5)
Reply
#7
Hi Bert,

So did you figure it out? You mentioned you thought the problem lies in those field names? The markup you posted looks fine.

How about this part? Did you try this out?

Quote:I'm not quite following you here... but in terms of seeing the info in Form Tools, I'd suggest doing this: temporarily change the field type for the "pr_naam" within Form Tools to a textarea field. That'll be easiest to see what values are actually being stored by Form Tools for each form submission. Once it's been ascertained that it is indeed storing multiple values (separated by a ", "), you can go back and change it back to a multi-select field with the appropriate dropdown values.

All the best!

- Ben
Reply
#8
Hi Ben,

Thanks again for your answer.
It doesn't seem to work out...
When I submit the same form to formtools vs 1.51 I have no problems at all..maybe something I overlooked in general?

Oh, I must say three comma's appear in one of the mentioned multiple select fields...

Greetings

Bert
Hi Ben,

I might have resolved the problem!

I adjusted the field types to select and multiselect and then back to textarea...and now the fields are filled in!

Still a little bit weird though....

Greetings

Bert
Reply
#9
Hi Ben,

A last question...

As you could see in the form I heve used a rule:

rules.push("digits_only,aantal_groen,alleen cijfers invullen!(groen)");

I would like users to give the opportunity to use a comma, si I tried:

rules.push("reg_exp,aantal_groen,^\s*(0|1|2|3|4|5|6|8|9|\,\)\s*$,i,alleen cijfers en komma!");

it doesn't seem to work....the form submits without java errors....

Any idea?

Hope you can help me with this.....

Thanks again!

Greetings

Bert van der Veen
Reply
#10
Hi Ben,

Sorry to bother you again...from your posts I know you must be very busy. Well so am I as you can see :-)

The so-called solution (better call it work-around I guess) I mentioned above works for FT 1.51 and for FT 2.0. Meaning: changing the multiple select fields within ft into text-area's solved the problem! (for me)
I would like to know however if the 'better' solution exists...

Also...couold you give me a hand with the reg_exp rule I tried to write mentioned above?

Quote:I would like users to give the opportunity to use a comma, I tried:

rules.push("reg_exp,aantal_groen,^\s*(0|1|2|3|4|5|6|8|9|\,\)\s*$,i,alleen cijfers en komma!");

it doesn't seem to work....the form submits without java errors....
Thank you for your help again!

Greetings

Bert
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)