COLUMN_TYPE = :decimal#, :precision => 12, :scale => 2
HoboFields.register_type(:currency, self)
def to_html(xmldoctype = true)
"$#{number_with_precision self, :precision => 2}"
end
end
I wish I could specify the precision and scale here but that doesn't work the last I checked so I need to have the field in the model setup as:
cost :currency, :precision => 12, :scale => 2
But it works so moving on.
My problem is in setting up the tag to go along with the rich type. I have the following so far based again on the jquery calendar tag
<def tag="input" for="Currency">
<currency format="c" decimals="2" merge/>
</def>
<def tag="currency" attrs="name"><%
options, attrs = attributes.partition_hash(['culture', 'decimals', 'downArrowText', 'format', 'max', 'min', 'placeholder', 'spinners', 'step', 'upArrowText', 'value'])
events, html_attrs = attrs.partition_hash(['change', 'spin'])
add_data_rapid!(html_attrs, "kendoNumericTextBox", :options => options, :events => events)
name ||= param_name_for_this %>
<%= text_field_tag(name, this, deunderscore_attributes(html_attrs)) %>
</def>
Two issues so far.
First the first tag isn't get used by default for currency fields.
If I work around it by manually calling the second tag as per below the input tag looks fine but the kendoNumericTextBox function is never called to convert the standard text box over. I don't see how that is done for the calendar control.
Work around to manual call the second tag
<field-list size="8" columns="2" fields="price, cost">
<cost-view:><currency/></cost-view:>
</field-list>
Any help in understanding all this would be appreciated. I hope to add a few other kendoui controls once I figure out how this all works. I'll of course make it all available as a gem for others to use assuming I ever get it working properly.
Bob