DRYML - using something other than model "name" field for field-list, and field-list style

42 views
Skip to first unread message

Banjoey

unread,
Sep 27, 2011, 10:29:40 AM9/27/11
to Hobo Users
I have a model that I'm trying to create a detailed view for (a second
"show" action). I am generally happy with everything field-list gives
me, but I have a couple desired changes.

First, I want the spacing to be less on it. I generally only want this
on the "detail" version of the rendered table, so should I surround
that with a div and then style the div in application.css?

Second, I have a few fields that are references to either belongs_to
or has_many fields. Is there a way for me to tell field-list that I
want to use the output from a custom tag I created for each of those
instead of it just using the "name" tag for those models? If not, is
there a way I could define a dynamic "name" (that say uses several of
the fields in conjunction) instead of just using one of the fields in
each model?

Thanks,
Joey

kevinpfromnm

unread,
Sep 27, 2011, 12:29:54 PM9/27/11
to hobo...@googlegroups.com
Easiest to describe with an example.  In your show.dryml

<show-page>
  <field-list: class="some-class-name">
    <association-name-view:><view:custom_name_method /></association-name-view:>
  </field-list:>
</show-page>

Then put your custom css in application.css

It is possible to do a dynamic name by just defining a name method in the model in question.  Sometimes you lose out on some of the automatic features IIRC but can't remember what those are.

Banjoey

unread,
Sep 28, 2011, 10:39:13 AM9/28/11
to hobo...@googlegroups.com
Thanks Kevin.

I have the classing to work for my css now, but for some reason I'm not seeing the change to the view for the association name. So for instance, I have the custom_name_method tag declared in another dryml file (under the application directory in taglibs) as this:

<def tag="custom_name_method">
  <a>
    <view:street_address1/><br/>
    <if:street_address2><view/><br/></if>
    <view:city/>, <view:state/> <view:zip_code/><br/>
  </a>
</def>

And I call the field list in the same file as the custom_name_method tag like this:

<def tag="show-some-info">
  <body: param>
    <field-list class="some-class-name" fields=" 
      association_name,
      some_other_field" 
    param/>
        
  </body:>
</def>


Do I need to put these tags in another file, or perhaps change the <view:custom...> to something else? Sorry for the ignorance. My brain's having a tough time comprehending DRYML... :(

kevinpfromnm

unread,
Sep 28, 2011, 1:05:09 PM9/28/11
to hobo...@googlegroups.com
I don't see anyplace where you're overriding the view in the field-list call.  The parameter used for the view part is association-name-view.  Note that any underscores in the association get changed to hyphens.

Banjoey

unread,
Sep 28, 2011, 1:18:55 PM9/28/11
to hobo...@googlegroups.com
Oh, sorry about that. I didn't post it because it was so close to your original sample. Here is what I have in detail.dryml (which is the name of the new show):

<def tag="show-page-new"> 
  <show-page merge>
    <content-body:> 
      <show-some-info with="&this"/>
    </content-body:> 
    <field-list: class="some-class-name">
      <association-name-view:><view:show-some-info/></association-name-view:>
    </field-list:>
  </show-page>
</def> 

<show-page-new/>

I've double-checked to make sure that all the _ are now -. Is it possible I'm messing up somehow in the show-page merge stuff?

Sorry for all the trouble...

kevinpfromnm

unread,
Sep 28, 2011, 1:28:12 PM9/28/11
to hobo...@googlegroups.com
Aside: curious why you're redefining this page.  Is it used in more than one place?

When working with parameters I always start with some plain text to make sure I've got it in the right place.  You can often guess at the parameter name as it adds a class with the parameter name to the element (by inspecting the html).

But here, I think you're calling your new tag wrong.  It should be <custom-name-method />, not <view... />.  Also, your custom tag should be complaining about the use of _'s in the name.

Banjoey

unread,
Sep 28, 2011, 2:09:44 PM9/28/11
to hobo...@googlegroups.com
<Blushes with ignorance>

I have a model that is a "group" of these models. I'm currently just trying to create a new "detailed" view of the single model, and then I will create a detailed view of the "group" model, which I thought I could just call from the individual one. That may very likely not be the best approach.

I changed the call from <view:...> to just my custom tag name. Also, I typo'd that above, I don't have _ in the name. Finally, I did two things to simplify the issue. I took out everything in my custom one except an <h1>Text</h1> line, and I then called it farther down the page. It loads fine farther down, just not in the override. I also tried to change the override to just plain text but that didn't work either. No error, it just doesn't change for that field.

I'll keep digging and maybe I can narrow it down further.

kevinpfromnm

unread,
Sep 28, 2011, 2:57:53 PM9/28/11
to hobo...@googlegroups.com
if you don't get a change with plain text in the parameter, you've got the wrong parameter name.  Any calls to nonexistent params get silently dropped.

Banjoey

unread,
Sep 28, 2011, 4:22:20 PM9/28/11
to hobo...@googlegroups.com
I must have a problem with the nesting or something that is keeping it from transferring over properly. my field name is called home_address and I have this:

    <field-list: class="detail-instance">
      <home-address-view:>Test</home-address-view:>      
    </field-list:>

Is there something I can look for in the log file that would give me any additional info? Or alternately, is there a way I can set a break point and try to follow the path of what's being done in there?

Thanks again for all your help. I did get the css stuff working the way I wanted... :)

kevinpfromnm

unread,
Sep 28, 2011, 4:57:45 PM9/28/11
to hobo...@googlegroups.com
I don't know on a way to log or break and get useful info here.  I'd suggest looking in firebug to see what class is on the td that contains the home address data.

For instance, on my user page, the td holding the email address is this <td class="email-address-view">

Banjoey

unread,
Sep 28, 2011, 7:23:02 PM9/28/11
to hobo...@googlegroups.com
OK, turns out I had it correct, it just won't override in the detail.dryml page. I found the example code on the cookbook pages and put the code in the same place where I was calling the stuff and it works!

Thanks Kevin for all the help!!!

Joey
Reply all
Reply to author
Forward
0 new messages