[html-formfu] Adding a link to the output of a nested repeatable

Mike South msouth at gmail.com
Tue Jun 2 15:54:21 GMT 2009


Hi,

I have a form with a repeatable element (using
HTML::FormFu::Model::DBIC) representing an interviewee that lets me
edit the interviewee's firstname and lastname columns.  I also want a
link to appear next to each one that lets you edit the rest of the
details for an interviewee (like href="/interviewee/edit/[id]" ).
What is the best way to generate that link?

I was guessing plugin.  My thought was that I could attach the plugin
to the Hidden field that gets the id.  Within the plugin, I would look
at the id field, create the link, and add the link to the end of the
HTML that generates the hidden form field.  (Kludgy, but I just wanted
to get something working).  I don't even know if I can do that from a
plugin, but here's what I tried so far:

Using the code from StashValid, I tried to put a warning with the
value of the field.  However, 'valid' never returned true and the
param was always undefined (whether I asked for valid() or not).

Here is the plugin:

package HTML::FormFu::Plugin::Mike;
use strict;
use base 'HTML::FormFu::Plugin';

sub post_process {

    my ($self) = @_;

    my $form = $self->form;
    my $name = $self->parent->nested_name;
    warn "name is [$name]";

    if ( $form->valid($name) ) {
        warn "val is ".  $form->param($name);
    }
    else {
        warn "not valid!";
    }
}
1;

Here is how I attached it to the field
               elements:
                  - type: Hidden
                    name: interviewee_id
                    plugins:
                      - Mike

The field is getting written out correctly with a value, like this:

<input name="interviewees_1.interviewee_id" type="hidden" value="4" />

The 'name' gets warned out correctly:

name is [interviewees_1.interviewee_id]

but it's followed by

not valid!

(or, if I take out the condition, an uninitialized value warning).

I don't really know what to try next.

Thanks in advance for any help anyone can give.

mike



More information about the HTML-FormFu mailing list