You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Torsten Luettgert <t....@pressestimmen.de> on 2004/11/03 15:29:26 UTC

Another "auto-fill from %fdat" problem

Hi,

I just hit another problem. I'd expect the following code

[- %fdat = ('number' => '0'); -]
<input type="text" name="number">

to give me a text field with a pre-filled zero inside, but
instead I get an empty one. It works with values != 0, though.

Apparently $fdat{$fieldname} is only checked
for being "true". I suppose one can fix this in the syntax,
but the perlcode parts are beyond my comprehension.

Any help?

Thanks,
Torsten <t....@pressestimmen.de>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


RE: Another "auto-fill from %fdat" problem

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

The following patch fixes the problem:

  RCS file: /home/cvs/embperl/Embperl/Syntax/EmbperlHTML.pm,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EmbperlHTML.pm	20 Jul 2004 04:59:11 -0000	1.8
  +++ EmbperlHTML.pm	4 Nov 2004 06:19:14 -0000	1.9
  @@ -71,7 +71,7 @@
                   perlcode =>
                       [ 
                       'Embperl::Cmd::InputCheck (%$n%, %&*\'name%,
%&*\'value%, %&\'checked%) ;  %&=-type:radio|checkbox% ',
  -                    '$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', $fdat{%&*\'name%} || \'\') ;   %&!-value%',
  +                    '$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ;
%&!-value%',
                       '$idat{%&*\'name%}=%&*\'value% ; ',
                       ]
                   }) ;

To make it more readable, change   
  
$fdat{%&*\'name%} || \'\'

To

exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\'


Gerald



---------------------------------------------------------------------------
Gerald Richter            ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
  

> -----Original Message-----
> From: Torsten Luettgert [mailto:t.luettgert@combox.de] 
> Sent: Wednesday, November 03, 2004 3:44 PM
> To: embperl@perl.apache.org
> Cc: Luiz Fernando B. Ribeiro
> Subject: Re: Another "auto-fill from %fdat" problem
> 
> On Mi, 2004-11-03 at 16:35, Luiz Fernando B. Ribeiro wrote:
> > The %fdat hash is magical, since its a tied hash. I have 
> not tried but 
> > does it work if you use the following instead?
> > 
> > [- $fdat{'number'} = '0'); -]
> > <input type="text" name="number">
> 
> No, it doesn't work better this way (and yes, I omitted the 
> erroneos ")"
> from the code snippet :-)
> 
> Using "0 but true" works fine. Just 1, without '' around, 
> too. It really looks like the value is tested for truth, and 
> the field cleared unless it is true.
> 
> Greetings,
> Torsten <t....@pressestimmen.de>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Another "auto-fill from %fdat" problem

Posted by Torsten Luettgert <t....@combox.de>.
On Mi, 2004-11-03 at 16:35, Luiz Fernando B. Ribeiro wrote:
> The %fdat hash is magical, since its a tied hash. I have not tried but
> does it work if you use the following instead?
> 
> [- $fdat{'number'} = '0'); -]
> <input type="text" name="number">

No, it doesn't work better this way (and yes, I omitted the erroneos ")"
from the code snippet :-)

Using "0 but true" works fine. Just 1, without '' around, too. It really
looks like the value is tested for truth, and the field cleared unless
it is true.

Greetings,
Torsten <t....@pressestimmen.de>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Another "auto-fill from %fdat" problem

Posted by "Luiz Fernando B. Ribeiro" <lu...@engenhosolucoes.com.br>.
On Wed, 03 Nov 2004 15:29:26 +0100, Torsten Luettgert
<t....@pressestimmen.de> wrote:

> Hi,
>
> I just hit another problem. I'd expect the following code
>
> [- %fdat = ('number' => '0'); -]
> <input type="text" name="number">
>
> to give me a text field with a pre-filled zero inside, but
> instead I get an empty one. It works with values != 0, though.
>
> Apparently $fdat{$fieldname} is only checked
> for being "true". I suppose one can fix this in the syntax,
> but the perlcode parts are beyond my comprehension.
>
> Any help?

The %fdat hash is magical, since its a tied hash. I have not tried but
does it work if you use the following instead?

[- $fdat{'number'} = '0'); -]
<input type="text" name="number">

-- 
Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet
+55 11 4485-0136

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org