Ok... so you've got one model that's got 5 rows of which none are
common between the two types?  I'm not sure why you'd want to shoehorn
that in like that.  I would guess you've got some other model you want
to interchangeably relate to both types?  Either polymorphic
relationship or a named_scope to load multiple associations at once
would work better if this is the case.

On May 21, 9:36 pm, tjg <[email protected]> wrote:
> 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="&[email protected] == 'Image' ">
>                <DocumentImage-fields/>
>             </if>
>             <else>
>                <if test="&[email protected] == '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 
> athttp://groups.google.com/group/hobousers?hl=en.

-- 
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