Page 1 of 1

[SOLVED] Form Builder - PullDownFields

Posted: Sat Dec 29, 2007 11:02 am
by andym
Hi,

Specifying a value against each option seems to work fine if the values are non-sequential eg 7, 11, 16 but not if they are sequential.

I specified 0,1,2,3 but the values pulled into computed fields and the database are actually 1,2,3,4.

I worked around the problem for now but will try and post a solution once I have more time.

I suspect it is something going wrong in the construction of the array - you can see the html created is wrong.

A.

Re: Form Builder - PullDownFields

Posted: Wed Jan 02, 2008 11:34 pm
by andym
Hi,

OK - I think this is solved.

Line 55 in ComputedField.class.php

It does not deal with the fact that the value in a pulldownfield is not the value of the selection so I modified the code as follows:

                    if ($others[$ref]->GetFieldType() == 'PulldownField') //cwf mod 20080102
{  //cwf mod 20080102
                    $cwf_sel = $others[$ref]->GetValue()-1; //cwf mod 20080102
                    $cwf_val = $others[$ref]->GetOptionElement('option_value',
                    $cwf_sel, $default=""); //cwf mod 20080102
                    $procstr = str_replace('$fld_'.$tF,$cwf_val,$procstr); //cwf mod 20080102
                    } //cwf mod 20080102
                  else //cwf mod 20080102
                    { //cwf mod 20080102
                    if (is_numeric($others[$ref]->GetValue()))
                        {
                        $procstr = str_replace('$fld_'.$tF,
                            $others[$ref]->GetValue(),$procstr);
                        }
                    else
                        {
                        $procstr = str_replace('$fld_'.$tF,
                            '0',$procstr);
                        }
                        } //cwf mod 20080102


That seems to do the trick.

A.