Ignore the previous post - this works a lot better:
<def tag="select-many-custom" attrs="options, targets, param-name,
association-name, remove-label, prompt, disabled"><%
prompt ||= "Add #{this_field.titleize.singularize}"
options ||= this_field_reflection.klass.all(:conditions
=>this.conditions).select {|x| can_view?(x)}
association_name ||= 'id'
values = this
association_values = values.map { |v| v.send(association_name) }
@param_name = param_name || param_name_for_this
-%>
<div class="input select-many" merge-attrs>
<div style="display:none" class="item-proto">
<div class="item" param="proto-item">
<span></span>
<input type="hidden" name="#...@param_name}[]" param="proto-
hidden"/>
<input type="button" class="remove-item" value="#{remove_label
|| 'Remove'}" param="proto-remove-button"/>
</div>
</div>
<div class="items">
<set param-name="¶m_name_for_this"/>
<div class="item" param="item" repeat>
<span><%=( association_name != 'id' ? h(this.send
(association_name)) : h(this.to_s)) %></span>
<input type="hidden" name="#...@param_name}[]" value="@#{h
this.send(association_name.foreign_key)}" disabled="&disabled"
param="hidden"/>
<input type="button" class="remove-item" value="#{remove_label
|| 'Remove'}" disabled="&disabled"
param="remove-button"/>
</div>
</div>
<select merge-attrs="&{:disabled => disabled}">
<option value=""><prompt/></option>
<option repeat="&options.sort_by {|x| x.to_s.downcase}" value="@#
{this.id}"
merge-attrs="&{:disabled => 'true'} if (this.in?
(association_values))"><%= h this.to_s %></option>
</select>
</div>
</def>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---