There *is* magic, but it should probably have an 'under construction'  
sign on it.

I just set this up in an app I'm working on, where only some dates  
needed to be formatted / input differently. If you want to change it  
globally, you're probably better off redefining / extending the  
<input> tag for Date. (see the DRYML manual for details)

The "sometimes" solution looks like this:

- in an initializer (I've got a custom_types.rb, but you can do this  
anywhere):

HoboFields.field_types[:hinky_date] = Date
HoboFields::PLAIN_TYPES[:hinky_date] = Date
class Date
   COLUMN_TYPE = :date
end

- then in a taglib, you can do:

<def tag="input" for="text_date" attrs="name">
   <%= text_field_tag(name, this.to_s, attributes) %>
</def>

(I've got dates entered as formatted text - change it to another Rails  
helper as needed)

You can then declare the field you want to have the edit behavior as

fields do
   some_date :hinky_date
end

This works, but the twiddling with COLUMN_TYPE in Date is a little icky.

Ideally, one could declare a 'type alias', basically stating  
that :hinky_date is really :date but with another name. I'll have to  
remember to open a ticket for that.

--Matt Jones


On Sep 30, 2009, at 7:49 PM, Spiralis wrote:

>
> So, I definitively need to extend/redefine the  form for rendering it
> then? I was hoping for some declarative hobo-magic. I think Hobo has
> spoiled me... :)
>
> ~Ronny
>
> On Sep 30, 11:23 pm, kevinpfromnm <[email protected]> wrote:
>> It looks like it passes any attributes through to the select_date
>> helper which has an option for start_year and end_year (as attributes
>> start-year and end-year respectively).  The trick is you need to pass
>> integers via the attributes.  Something like <input start- 
>> year="&1900"
>> end-year="&2009" />
>>
>> On Sep 29, 9:22 pm, Spiralis <[email protected]> wrote:
>>
>>> This should have been simple, and it probably is. I have a date- 
>>> field
>>> in my app. How do I go about to change the default range that the  
>>> web-
>>> interface present. Basically, it is showing years, months and days.
>>> But, the year range is the rails default which is +/- 5 years from
>>> today. I want it to create options from 1900 and upto this year. How
>>> do I do that?
>>
>>> Thanks,
>>> Ronny
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to