Hornet | 5 Feb 23:43
Picon

[FormBuilder] Default Values.

Hello All,

Just want to start out by saying, this is a really great API and easy
to use. Which must be my problem. Below is the code I'm working with.
The problem I'm having is that I can't get the radio button or
checkbox to be either on or off. The $notact with either be 1 or 0,
yet nothing is checked. I thought I was doing what the documentation
was telling me. Can anyone see what I'm doing wrong?

sub edituser {
	&noauth if !&admin;
	&phead;
	my $stmt="select Users.Username, Users.Password, Users.BmsCustId,
Users.Email, Users.FullName, Users.NotActive, Groups.Group as fGroup
		from Users
	        left join Groups on Groups.pkey = Users.Group
		where Users.pkey=$input{edituser}";

	my $h=$dbh->selectrow_hashref($stmt);
	print dumper_html($h);
	my $notact=$h->{NotActive};
	delete $h->{NotActive};
	
	my $group=$dbh->selectall_arrayref("select Groups.Group from Groups");

	$form = CGI::FormBuilder->new(
			fields =>$h,
			smartness => 2,
	);
	$form->field(name=>'NotActive', value=> $notact, options=>"Deactivate
(Continue reading)

Nate Wiger | 6 Feb 18:11
Picon

Re: [FormBuilder] Default Values.

On 2/5/07, Hornet <hornetmadness <at> gmail.com> wrote:
> Hello All,
>
>         my $notact=$h->{NotActive};
>         delete $h->{NotActive};
>
>         $form->field(name=>'NotActive', value=> $notact, options=>"Deactivate
> account");

Your options have to contain your value. For example:

   $notact = 1;   # inactive
   $form->field(name => 'notact', label => 'Not Active', value => $notact,
                     options => [[1, 'Deactivate account']])

Or, if instead you wanted a radio group:

   $form->field(name => 'notact', label => 'Activate Account?', value
=> $notact,
                     options => [[1, 'Yes'], [0, 'No']])

Either of these alternatives will display the 'Text' shown, but return
the value (ie, 1 or 0) to your script.

-Nate
_______________________________________________
FBusers mailing list
FBusers <at> formbuilder.org
http://www.formbuilder.org/mailman/listinfo/fbusers

(Continue reading)

Hornet | 12 Feb 16:12
Picon

Re: [FormBuilder] Default Values.

On 2/6/07, Nate Wiger <nwiger <at> gmail.com> wrote:
> On 2/5/07, Hornet <hornetmadness <at> gmail.com> wrote:
> > Hello All,
> >
> >         my $notact=$h->{NotActive};
> >         delete $h->{NotActive};
> >
> >         $form->field(name=>'NotActive', value=> $notact, options=>"Deactivate
> > account");
>
> Your options have to contain your value. For example:
>
>    $notact = 1;   # inactive
>    $form->field(name => 'notact', label => 'Not Active', value => $notact,
>                      options => [[1, 'Deactivate account']])
>
> Or, if instead you wanted a radio group:
>
>    $form->field(name => 'notact', label => 'Activate Account?', value
> => $notact,
>                      options => [[1, 'Yes'], [0, 'No']])
>
> Either of these alternatives will display the 'Text' shown, but return
> the value (ie, 1 or 0) to your script.
>
> -Nate
>

Nate,

(Continue reading)


Gmane