[SOLVED] Form Builder - PullDownFields

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
andym
Forum Members
Forum Members
Posts: 31
Joined: Mon Dec 24, 2007 9:00 pm

[SOLVED] Form Builder - PullDownFields

Post 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.
Last edited by andym on Wed Jan 02, 2008 11:34 pm, edited 1 time in total.
andym
Forum Members
Forum Members
Posts: 31
Joined: Mon Dec 24, 2007 9:00 pm

Re: Form Builder - PullDownFields

Post 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.
Post Reply

Return to “Developers Discussion”