# Datebox\_engine with multiple dateboxes on same form

**URL:** <https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467>\
**Category:** Engines\
**Created:** [February 17, 2006, 1:54am UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467 "2006-02-17T01:54:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [February 17, 2006, 1:54am UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467/1 "2006-02-17T01:54:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [February 17, 2006, 3:00am UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467/2 "2006-02-17T03:00:59Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [February 17, 2006, 8:04pm UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467/3 "2006-02-17T20:04:58Z")

</div>

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](mailto:removed_email_address@domain.invalid) wrote:

> ```auto
> > 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

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [February 18, 2006, 1:44am UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467/4 "2006-02-18T01:44:18Z")

</div>

On 2/16/06, Nathaniel S. H. Brown [removed\_email\_address@domain.invalid](mailto: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.

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [February 24, 2006, 1:59am UTC](https://www.ruby-forum.com/t/datebox-engine-with-multiple-dateboxes-on-same-form/69467/5 "2006-02-24T01:59:28Z")

</div>

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?
