Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Formbuilder: generate id, that includes formname

by Wolfgang (Novice)
on Sep 30, 2009 at 10:26 UTC ( [id://798282]=note: print w/replies, xml ) Need Help??


in reply to Re: Formbuilder: generate id, that includes formname
in thread Formbuilder: generate id, that includes formname

CGI::Formbuilder was the one I talked about (which in my case was called by Catalyst::Controller::FormBuilder).

the form-name is only used for the name of the form, not as an prefix for the name of the fields inside the form.

if the prefixing works for you, can you show me some lines how you configure it to work?

Wolfgang

Replies are listed 'Best First'.
Re^3: Formbuilder: generate id, that includes formname
by Anonymous Monk on Sep 30, 2009 at 11:23 UTC
    the form-name is only used for the name of the form, not as an prefix for the name of the fields inside the form

    I see, a misunderstanding. Documentation shows

    <tr id="${form}_${field}_row"> <td id="${form}_${field}_label">Label</td> <td id="${form}_${field}_input"><input tag></td> <td id="${form}_${field}_error">Error</td><!-- if invalid +--> </tr>
    And that matches my experience (s/_input/_field/), this code
    #!/usr/bin/perl -- use strict; use warnings; use CGI::FormBuilder; my $form = CGI::FormBuilder->new( name => 'acctinfo'); $form->field(name => 'fname', label => 'First Name'); $form->field(name => 'lname', label => 'Last Name'); print $form->render(header => 1);
    produces this html It seems you want
    #!/usr/bin/perl -- use strict; use warnings; use CGI::FormBuilder; my $form = CGI::FormBuilder->new( name => 'acctinfo'); $form->field(name => 'acctinfo_fname', label => 'First Name'); $form->field(name => 'acctinfo_lname', label => 'Last Name'); print $form->render(header => 1);
      You are right, that is want I want. Things are somewhat different though, because since I'm using catalyst I also have the .tt-Files (HTML) and the .fb (form definition) to consider.

      To make matters worse I'm working in an environment where the package ext (JS-Package) loads the html via ajax. JS inside of the html therefore will not be executed (in a consistent way, considering all browsers).

      Because I (want to) use the same perl construct in several html-templates the predefined js-functions have to be able to identify the correct formbuilder-element. Eventually I ended up with this solution:

      CGI::FormBuilder::Source::File lets me define an additional id, if I do so, formbuilder will use this and not create its own. That is true for the form element as well as for the input-elements.

      Even better, in the html-template I can ask the formbuilder input object for its id. The only minor flaw is, that the id of the form object can not be found this way

      So I have to enter that id in several files, which kind of bugs me and causes bugs ;-)

      Guess, I'll have to live with it

      Thanks anyway

        Guess, I'll have to live with it

        Nooooo! :) CGI::FormBuilder hasn't been updated since 02 Mar 2007, I say you take over, or fork the project :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://798282]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-20 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found