Datebalks Discussions > Feature Requests

If you know of a feature that could be useful in Datebalks then post a reply to this message.

Jan 31, 2008 | Registered CommenterEric Methot

I believe that it would be wise to change the datebalks hidden field suffix from _text to something less likely to collide with a user defined attribute name. I suggest __dteblk__ or __dtbk__ (double underscore)

Mar 26, 2008 | Unregistered CommenterJames B. Byrne

As presently implemented the datebalk hidden fields are added to the params hash and returned to the controller. When a model attribute is assigned to class datebalks inside a form_for block this means that the model class receives an undefined method back from the view. There are a couple of ways of dealing with this difficulty in the model and in the controller but it seems best that the hidden field simply be discarded immediately after use in the view and recreated as required.

Mar 26, 2008 | Unregistered CommenterJames B. Byrne

James,

The choice of the _text suffix was for me natural as I often wanted to store the user input in the database and my models had the attribute anyways. When I didn't need it I added an attribute accessor so as to avoid all of the problems that you mention above. The problem I see with the current approach is that you generate one field and get two back but I "solved" dissonance by using convention: this is the way datebalks works.

I will take a look to see if I can't add an option, even if global, to have the _text field ditched before the form is submitted.

Mar 26, 2008 | Registered CommenterEric Methot

It turns out that ditching the _text field is not that simple. For a regular form I could try to intercept the submit event and delete the input then. But this is tricky and it could interfere with existing onsubmit attributes (Rails is full of those). When forms use XHR (Ajax) we can't delete the element because we will loose the ability to re-use the form later. But we could easily remove the field from the serialized values before submission. Nothing consistent.

I'm not saying that there is no way to solve this but having a _text attribute in your models (even if you don't save it to the database) is much easier and far less error prone.

Food for thought...

Mar 26, 2008 | Registered CommenterEric Methot