[Nitro] date_select bug
Emmanuel Piperakis
epiperak at softlab.ece.ntua.gr
Mon Sep 19 23:10:08 EDT 2005
I would like to report that the xhtml.rb/date_select function should be
changed starting the values from 0 and not from 1 for months select. As
is, the select has an empty choice (not good) and it also keeps on
incrementing the values everytime a save to the db occurs (the values
1-12 do not correspond to the representation of the db).
.fill also does not work with the dates, they have to manually be assigned
to the objects and then saved, in which case the month value (created from
the date_select) has to be decreased by 1 in order to be saved correctly
to the db.
<code-in the controller>
request.fill(project)
project.acquisition_date = Date.new(request['acquisition_date']['year'].to_i,
request['acquisition_date']['month'].to_i-1,
request['acquisition_date']['day'].to_i, Date::ITALY)
<code-custom date_tags for use as a row in a table>
def my_date_tag(label, id, name, val = nil)
str = %{<tr><th>#{label}</th><td>}
str << %{#{date_select(val, :name => name)}} if val != nil
str << %{#{date_select(Date.today, :name => name)}} if val == nil
str << %{</td></tr>}
return str
end
<code-in the template>
<form method="post" name='pr_d_update'
action='project_save/domestic/update'>
<input type="hidden" name="oid" value="#{@project.oid}" />
<table class="myform">
#{my_date_tag(@l_contract_date,'project_contract_date','contract_date', at project.contract_date)}
</table>
</form>
I have 2 suggestions:
1) All tags should support localization, default (selected) values,
variable ranges (for years eg), name definition (they have them now, but
they do not work for dates, ...)
2) Automatic form generation should have on/off switches for elements of
the object in order to display only the on ones.
Due to lack of time, I can not do the devel myself, if those changes are
not incorporated in the next Nitro version, then from October they will be
in my TODO: list...
Thanx
Emmanouil Piperakis (epiperak at cs.ntua.gr)
{To explore is Human, to Create is Devine,
To teach is Primal, to Rule is Sin}
More information about the Nitro-general
mailing list