I have a model where I want the name in the cards to appear like this:
"45 - My name"

My first thought was to just add a name method to the model to
override the attribute, like this:

def name
    return "##{id} - #{self[:name]}"
end

It worked, except for the new/update forms, where the record will load
and then add the id in the name field. In new it would then display "#
-" in the field instead of it being empty. In update it adds the
number to the name field, like this: "#3 - This is a name". Saving
means it will display "#3 - #3 - This is a name", etc.

I then tried to add a full_name method to the model instead, and
wanted to reference that in the card heading instead. This means that
the forms are not affected. So, to get the full-name instead of the
old name I needed to change the card-definition. This is the original
definition that is auto-generated:

<def tag="card" for="Comment">
  <card class="comment" param="default" merge>
    <header: param>
      <h4 param="heading"><name/></h4>
    </header:>
    <body: param>
      <view:body param="description"/>
      <a:owner param="creator-link"/>
    </body:>
  </card>
</def>

Here is my extension in front_site.dryml:
<extend tag="card" for="Comment" >
  <old-card class="comment" param="default" merge>
    <heading: replace>
      <h4 param="heading"><view:full-name/></h4>
    </heading>
  </old-card>
</extend>

Using this gives the right display-name, but the name is no more a
link. While trying various things here I discovered that the automagic
linking gets lost even if I just try to redefine the heading the same
way it was before:

<extend tag="card" for="Comment" >
  <old-card class="comment" param="default" merge>
    <heading: replace>
      <h4 param="heading"><name/></h4>
    </heading>
  </old-card>
</extend>

This redefinition makes the link to the record go away too. I found
that very strange indeed... Anyone know why this happens?

Does anyone have a suggestion on how to change the display-name
without any other adverse effects?

Regards,
Ronny

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