#676 ✓resolved
Iain

<field-list> using sub rather than gsub to generate label names

Reported by Iain | March 24th, 2010 @ 01:29 AM

I've just noticed that the tag uses the sub method to replace '.' with '-' in it's parameter names, whereas it should be using gsub (this is what table does).

Here's the code:

      <labelled-item unless="&tag == 'input' && no_edit == 'skip' && !can_edit?">
        <item-label param="#{scope.field_name.to_s.sub('?', '').sub('.', '-')}-label" unless="&field_name.blank?">
          <do param="label"><%= field_name %></do>
        </item-label>
        <item-value param="#{scope.field_name.to_s.sub('?', '').sub('.', '-')}-view" colspan="&2 if field_name.blank?">
          <do param="view"><call-tag tag="&tag" param="#{scope.field_name.to_s.sub('?', '').sub('.', '-')}-tag" merge-attrs="&input_attrs"/></do>
          <div param="input-help" if="&tag.to_sym == :input && !this_field_help.blank?"><%= this_field_help %></div>
        </item-value>
      </labelled-item>

This is a problem when you're trying to display a field that's more than one-level deep, eg. an attribute of something in an enumerable that's in your model. In my case I'm trying to display "..count", and field list is naming the label parameter for this field "-.count" which I then can't access inside my DRYML (you can't have "." in a tag name).

This should be an easy fix... I'd apply it myself but I haven't got a working github repo at the moment (sorry!)

Comments and changes to this ticket

  • Bryan Larsen

    Bryan Larsen March 25th, 2010 @ 06:04 PM

    • Tag changed from rapid to defect, rapid
    • State changed from “new” to “resolved”

    and I just pulled, tested and pushed the fix. Thanks!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Tags

Pages