FLOW3: Create a select box mapping to a list of objects in a Fluid view

FLOW3 rocks. However, the current documentation is… well… a bit short 🙂 The quickstart guide and the blog example show you the basics of working with FLOW3 and Fluid, its templating engine. But for explanations or examples of even the slightest more complex functionality you have to search the web for quite some time (or at least I had to ;-)).

Like today: I wanted to map an object of type Invoice to an object of type Client in a Fluid view. How do you do that, so that FLOW3 instantiates a real Client object and hands it over to the Invoice object upon its instantiation? It turns out, all you have to provide the framework to magically do that, is something like a select tag with the Client objects‘ GUIDs like this:

  1. <select name="client">
  2.   <option value="80f870ee-931c-4706-8716-fb3e52bbe450">Client 1</option>
  3.   <option value="fb2cd21e-64e8-439b-bff2-be51948b8ff5">Client 2</option>

But how do you do that using Fluid? I found the solution (mainly by chance) here: FLOW3 – your first relation between to models.

  1. <f:form.select property="client" name="client" options="{clients}" optionLabelField="name" />

If you omit the attribute optionValueField on the view helper f:form (see Fluid ViewHelper Reference), the objects‘ GUIDs are magically used for the values of the options in the HTML form and FLOW3 figures out that it has to instantiate Client objects.

Über uns Stefan

Polyglot Clean Code Developer

2 Kommentare

  1. Pingback:Dj Turntable Packages | Record Players for Sale Here

  2. Pingback:Beating Problems to succeed in Your current Target | Amazon Lose Weight

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax