best_in_place icon indicating copy to clipboard operation
best_in_place copied to clipboard

:display_with is not being used when rendering :as=>:select

Open vanboom opened this issue 8 years ago • 1 comments

I have a BIP select that is based on an enum set and am trying to apply a class to the render to show inactive records in RED:

= best_in_place customer, :status, :as=>:select, :collection=>... , :display_with=> ->(c){format_customer_status(c)}

When the page is rendered initially, the display_with function is not called. I have confirmed that the helper proc is being called, however the rendered content_tag is not being sent to the view, only the attribute value.

If the status is changed using the BIP select, the new status renders perfectly.

vanboom avatar Feb 06 '17 16:02 vanboom

UPDATE: there is some mismatch between the way BIP renders the initial value in the best_in_place method vs. rendering the value on select.
Offending line 25 in helper.rb:

display_value = collection.flat_map{|a| a[0].to_s == value ? a[1] : nil }.compact[0]

This line sets the initial display value using the collection values, but does not use display_with or display_as

vanboom avatar Feb 06 '17 17:02 vanboom