Skip navigation

Charlie Harvey

| Back to navigation

Pages

Index / Geekery / Config::General arrayrefs and HTML::FormFu

Permalink

Config::General arrayrefs and HTML::FormFu

I'm in the process of making a nicer backend for charlieharvey.org.uk using Catalyst (which is lovely BTW). One of the things I'm playing with is using HTML::FormFu for making the forms. But this morning I got proper stuck on the simple task of populating a select box with options from my Config::General config file.

I know what you're going to say. How come you're not using YAML. Well, its mostly its weird treatment of tabs and spaces, which I've found annoying enough to make me dislike it. I once spent an hour at New Internationalist trying to debug a YAML config for FormBuilder. I ended up having to reindent one character at a time.

Anyhow the problem was pretty simple to solve in the end, but doesn't seem documented in exactly this context on the web much, at least not for the terms I was googling. If you want an arrayref for a select element in your HTML::FormFu form you need to specify multiple blocks with each block having a label and value for that option. Here's the one I used for my Writings media types.

<elements> name media id media type Select label Media size 1 <attributes> title Enter media type; href is special </attributes> <options> value txt label txt </options> <options> value href label href </options> <options> value pdf label pdf </options> <options> value ogg label ogg </options> <options> value odt label odt </options> <options> value sxw label sxw </options> </elements>

Kinda long-winded compared to the much nicer YAML way of doing it. But it works OK.

Comments

RSS   All comments on Config::General arrayrefs and HTML::FormFu

Leave your comment?

  • You can use strong, em, code, pre, q and a HTML tags.
  • Fields in bold are compulsory
  • Be respectful. You may want to read the comment guidelines before posting.






Privacy note: This form will forward your IP address, user agent and referrer to the Akismet, StopForumSpam and Botscout spam filtering services. I don't log these details. Those services will. I do log everything you type into the form. Full privacy statement.

Reactions

Tweet it: 73 | Digg it: 73




Author: Charlie Harvey

Updated: 2010-08-15T21:02:07