[html-formfu] FormFu basics

Christian Lackas christian at lackas.net
Mon Feb 9 11:15:52 GMT 2009


Hi Everybody,

I apologize for the questions below which are probably FA, however, I
don't get FormFu yet and did not find solutions for my problems in the
documentation or by scanning through the last three months of the
archive:

Here is what I want to have:
A user has selected an object and dragged it onto a calender (to select
a date) and then a window opens where the user can set details for an
event with said object and date.

Here is the event form, depicting what I would like to do:

    ---
    id: form
    auto_fieldset:
      legend: Event [% date %]

    elements:
      # Hidden data selected by the user earlier
      # should be filled in controller/stash
      - type: Hidden
        name: objectid

      - type: Hidden
        name: date

      # Should display object name behind id
      # no input, just plain text
      - type: Block
        name: object
        label: Object
        value: [% object.name %]

      - type: comment
        name: Text
        label: Comment

Can I somehow use stash variables in the form? Or what is the right way
to for instance set the fieldset label to contain the date of the event.
I use FormConfig and then in my method:

    my $form = $c->stash->{form};
    $form->get_element({type => 'Fieldset'})->{legend} = 'New Event '.$date;

which I don't like (due to the direct access to the Hash, however,
legend() is no valid rw accessor, but produced by mk_ouput_acceccors()).

Next point, I don't understand how I set the default values for a form.
I cannot use the DBIC model, since the event was not yet created,
however, I already have a couple of fields (objectid and date), which
should be used when actually creating the event. And how can I access
related fields such as object.name (event belongs to object, and object
has many events).
Displaying the object.name (which should not be changeable) should be
plain HTML, so no input field (actually it should be a <div
class="object[% object.type %]">, since my objects are color coded).

Thanks for any input. Willing to read TFM, however, I found the
HTML::FormFu documentation to be confusing (probably mainly because I am
missing some basics).

Best regards,
 Christian





More information about the HTML-FormFu mailing list