David Baird | 2 Aug 18:00
Picon

possible bug in CGI::FB::Field

Hi,

In CGI::FB::Field::value(), line 186, a manually supplied value is 
passed through cleanargs().
This has the effect of changing a single value into a hashref, and has 
the side effect of turning on the 'multiple' flag in a select widget.

While I'm here, the website seems to be down.

Cheers,

d.

Nathan Wiger | 2 Aug 19:21
Picon

Re: possible bug in CGI::FB::Field

David Baird wrote:
> Hi,
> 
> In CGI::FB::Field::value(), line 186, a manually supplied value is 
> passed through cleanargs().
> This has the effect of changing a single value into a hashref, and has 
> the side effect of turning on the 'multiple' flag in a select widget.

Ok, I see where you're pointing. Can you send me a snippet that 
illustrates this?

> While I'm here, the website seems to be down.

Fixed (oops)

-Nate

David Baird | 3 Aug 00:18
Picon

Re: possible bug in CGI::FB::Field

Nathan Wiger wrote:

> David Baird wrote:
>
>> Hi,
>>
>> In CGI::FB::Field::value(), line 186, a manually supplied value is 
>> passed through cleanargs().
>> This has the effect of changing a single value into a hashref, and 
>> has the side effect of turning on the 'multiple' flag in a select 
>> widget.
>
>
> Ok, I see where you're pointing. Can you send me a snippet that 
> illustrates this? 

I can't quite convince myself this is a bug. Seems to be that if I 
partially build a field, and then later on, try to set its value, the 
problems occur. I can get around this in my app, which suggests it's my 
usage that's wrong. Still, cases 3 and 4 in the two scripts attached 
seemed to be almost reasonable behaviour, and they show the problem.

Cheers,

d.

#!/usr/bin/perl -I.

(Continue reading)

Nate Wiger | 3 Aug 00:50
Picon
Gravatar

Re: possible bug in CGI::FB::Field

> I can't quite convince myself this is a bug. Seems to be that if I
> partially build a field, and then later on, try to set its value, the
> problems occur. I can get around this in my app, which suggests it's my
> usage that's wrong. Still, cases 3 and 4 in the two scripts attached
> seemed to be almost reasonable behaviour, and they show the problem.

Yeah, it's a bug. Using cleanargs() there is a mistake. I just fixed
this in the 3.03 tree by splitting cleanargs() into arghash() and
arglist()  (since some subs want hashes and others arrays).

In the meantime, in the script, you can do this:

   $form->field(name => 'foo', value => ['bar']);

And that will have the desired effect, without setting 'multiple'.

-Nate

Bob McClure Jr | 3 Aug 01:38
Picon
Favicon

Selecting 0 in select list yields nothing

I'm using CGI::FormBuilder v3.0202, CGI v3.09, and Perl v5.8.6.

I'm having problems with a select list.  The application sometimes
needs to collect the user's height in feet and inches.  I set up the
code like this:

if(defined($height_collect) && $height_collect)
{
	my $reqd = 0;
	my $label = "Height";
	if(defined($height_required) && $height_required)
	{
		$reqd = 1;
	}
	else
	{
		$label .= " (optional)";
	}
	$form->field(name => "height_feet",
				 label => $label,
				 comment => "Feet",
				 options => [ 1 .. 8 ],
				 );
	$form->field(name => "height_inches",
				 label => "",
				 comment => "Inches",
				 options => [ 0 .. 11 ],
				 # This could be "0"
				 # which will otherwise bust validation.
				 validate => 'INT',
(Continue reading)

Arthur | 12 Aug 23:32
Favicon

use javascript

I use template file, and there are two dropdown lists in my form (products and 
builds).  The sencond dropdown list (builds) depends on the user's selection on 
the first list.  So I tried to use javascript, in my cgi file, I initilaized 
the product list:

$form->field('name'    => 'product',
               'onchange' => 'filter_builds()',  #assign JS function here
               'type'    => 'select',		
               'options' => \@product_cache);

in my tmpl file, I tried both to insert the javascript code or use external js 
file.  But it doesn't work in either way.  

   Anyone has idea how to use javascript in such case? Thanks in advance.

Arthur

Todd Charron | 19 Aug 23:00
Picon

Formbuilder, HTML Template and multiple forms on one page

Hello,

I've recently started using formbuilder in conjunction with HTML Template to 
make templated forms.  I've come across a situation I'm not quite sure how to 
handle.

I'm trying to have one template file (let's say example.tmpl) and that 
template file may or may not include other templated files (shouldn't be 
relevent for this question).

So here's the deal.  I'd like to have multiple forms on the page output by 
example.tmpl but I'm not quite sure the best way to do that with formbuilder.  
HTML Template only has <tmpl_var form-start> and doesn't seem to allow any 
way to distinguish forms (e.g. a name="formname" attribute).

Now it appears I could template out a header, than create a new form instance 
for each form and close it with a footer template.   That's a bit awkward and 
would also break formbuilders javascript validation (since the <script> tags 
couldn't be included in <head></head>).  There's got to be a better way to do 
it than that.  

Many sites have a login area on one form and a poll on another form all in the 
same page (i.e. www.slashdot.org) so it is a pretty common situation.  I just 
can't seem to figure out the formbuilder/HTML Template way of handling it.

Thanks.

Todd

(Continue reading)

Jonas Smedegaard | 21 Aug 16:09
Picon
Favicon
Gravatar

other doesn't work with multiple


Hi,

I think I have found a bug, in that the following does not work correctly:

$form->field(
        name    => 'abc',
        options => [ 'foo', 'bar'],
        type    => 'checkbox',
        other   => 1,
),

If you add something in the "other" field and also selects one or more
of the static items, the other field is greyed out - even if you
deselect those static items again. At least that's the case with Mozilla
Firefox as of today (in case this is something browser-specific).

 - Jonas

--
* Jonas Smedegaard - idealist og Internet-arkitekt
* Tlf.: +45 40843136  Website: http://dr.jones.dk/

 - Enden er nær: http://www.shibumi.org/eoti.htm
Nathan Wiger | 22 Aug 20:43
Picon

Re: Using formbuilder from within a sub routine

Todd Charron wrote:
> Hi,
> 
> One of these sub routines will be &displayform (which uses formbuilder to 
> create a form).  The form creates fine, etc.  However, $form->submitted never 
> gets set when the form is submitted.  $form->submitted only gets set if the 
> form building code is in main.cgi.  ($form->validate also appears not to work 
> when formbuilder is used in the sub routine, though the javascript generates 
> and works fine.)  If I take all the code out of the sub routine and use it in 
> its own script it works fine.  Is there a way to work around this other than 
> ripping out all of the sub routines and dumping them into the main script?  
> Thanks.

You'll probably need to pass your $form object into each sub. Without 
seeing the code I'm not sure exactly what's going on, but you should 
probably have something like this:

    use strict;

    sub create_form {
        return CGI::FormBuilder->new(%options);
    }

    sub display_form {
        my $form = shift;
    }

    sub validate_form {
        my $form = shift;
    }
(Continue reading)


Gmane