Datebox_engine with multiple dateboxes on same form


#1

I’ve got the datebox engine working fine if I just have one datebox on a
form.

It is a very nice little gui.

How do I configure it to handle multiple date boxes corresponding to
multiple table fields?

Thanks
Greg

Greg F.
The Norcross Group
Forensics for the 21st Century


#2

That feature hasn’t been added yet.

I have a few emails outlining how someone did it, but haven’t integrated
it
into a new version yet.

Feel free to submit patches, or example code how you manage to do it if
you
get around to it.

-Nb

 Nathaniel S. H. Brown                           http://nshb.net

#3

Just realized I got ahead of myself.

I have reduced the databox’s down to one on each of two forms.

They both appear to work from a gui perspective, but when I do a save
nothing changes in the DB.

Thus if I’m creating a new record the date field ends up blank. If
I’m editing an exiting record, the date field remains unchanged.

Any idea what I’m doing wrong?

On 2/16/06, Nathaniel S. H. Brown removed_email_address@domain.invalid wrote:

> Subject: [Engine-users] datebox_engine with multiple
> Thanks
>

_______________________________________________
engine-users mailing list
removed_email_address@domain.invalid
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org


Greg F.
The Norcross Group
Forensics for the 21st Century


#4

On 2/16/06, Nathaniel S. H. Brown removed_email_address@domain.invalid wrote:

That feature hasn’t been added yet.

I have a few emails outlining how someone did it, but haven’t integrated it
into a new version yet.

Feel free to submit patches, or example code how you manage to do it if you
get around to it.

-Nb

I’ve got this working I think. I did NOT have to modify the engine.

I’m still fairly new with ruby/rails so I’m sure there are more
elegant ways to handle this.

In my partial view (_form.rhtml) I have:

<%= @date_field1=@table.date_field1 date_box('date_field1') %> <%= @date_field2=@table.date_field2 date_box('date_field2') %> <%= @date_field3=@table.date_field3 date_box('date_field3') %>

As you can see I’m creating 3 distinct instance variables initialized
from my table. Then I’m passing the name of the instance variables
into date_box.

FYI: I tried directly passing in table.date_field1, but it croaked for
some reason I don’t understand.

Question: Is there a end of line character like ; in C to allow the
above to be on one line each?

With the above the existing unmodified engine causes the 3 new
instance variables to be available as params so in my controller I
updated my update and create methods to have:
@table.date_field1 = params[:date_field1]
@table.date_field2 = params[:date_field2]
@table.date_field3 = params[:date_field3]

The above is immediately after the table.find(params[:id]) line in
both the update and create methods.

I never did get the automatic database field updating feature to work
with even a single date. For someone that has that feature working
maybe they could eliminate having to add the extra lines to the update
method.

HTH
Greg

Greg F.


#5

You can always just use a ; to separate Ruby statements…

Question: Is there a end of line character like ; in C to allow the
above to be on one line each?