Not sure if I'm overlooking some more obvious approach, but in my
attempts to avoid STI, subclasses etc. (and maximize my learning of
Hobo essentials first), I decided to simply try to make show and edit
forms for a 'document' model decide which fields to show based on an a
'type' attribute of the document.

In extending the edit form for the model, I did this (in
application.dryml):

<def tag="DocumentImage-fields">
  <field-list fields="caption, imageformat" param/>
</def>

<def tag="DocumentText-fields">
        <field-list fields="title, content" param/>
</def>

<extend tag="form" for="Document">
   <old-form merge>
      <error-messages param/>
         <!-- Decide which fields to show depending on document nature
-->

            <if test="&@document.type == 'Image' ">
               <DocumentImage-fields/>
            </if>
            <else>
               <if test="&@document.nature == 'Text' ">
                  <DocumentText-fields/>
               </if>
           </else>

   </old-form>
</extend>

This works wonderfully.

But if I continue to add news types of documents the <if> and <else>
nesting will get pretty hairy.

Is there a more Hobo-centric way of tackling "switch" or "case" tests
like this within a tag definition? Or, is there some programmatic
feature of Hobo I am overlooking?

Many thanks,
Tim

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to