Bugs: Browse | Submit New | Admin
When using a date_select, I can no longer use the ":include_blank => true" option. This is my code: <%= date_select 'newsletter', 'published_on', :include_blank => true %> and this doesn't work, either: <%= date_select 'newsletter', 'published_on', {:include_blank => true} %> Any ideas?
Add A Comment:
Date: 2006-10-13 09:06 Sender: Sean Cribbs I understand why it can have meaning, and I'd appreciate any patches people are willing to provide. However, the complexity it could bring to how form data is being handled might outweigh the utility of allowing nils. For example, what do you do when one select in the group is nil, but the rest are not? Although I haven't developed actively on this project for several months, I've thought of incorporating Bruce Williams' param_types plugin, which would solve a lot of these issues. Again, if you have a patch, please submit it. My real-life paying projects are pretty demanding right now, and I haven't had to use FT in a while, so I haven't actively developed it.
Date: 2006-10-12 18:24 Sender: Zack Chandler Actually a blank Datetime field can have meaning. What about a completed_on column. A null column in this case means that the the task has not been completed. I would recommend implementing the include_blank pass-through because there are numerous intances where a nil makes sense for a Datetime.
Date: 2006-05-31 11:44 Sender: Sean Cribbs You're spot on. The plugin won't allow nils to be stored, unfortunately. That's something I'll have to think about and factor in, perhaps.
Date: 2006-05-31 10:46 Sender: Joel Stein Forgive me for not totally understanding your explanation... I'm still new to Ruby (and Rails). I think I understand what you're saying about the datetime_column methods. But I also know that when I don't use your plugin, and use a datetime_select with :include_blank, Rails stores empty dates in the database as nil. ??? Where would I have to look to see the code for such functionality?
Date: 2006-05-31 10:41 Sender: Sean Cribbs I see your point, and it's a good one. My concern is that if the helper exists in the form, it will be stored in the database, and thus not be null/nil. The AR methods (datetime_column etc.) that marshal data from the Hash format into a Date or Time object use the current Date or Time as the default and update the appropriate fields within those objects with the passed data. This allows you to update only a few portions of the database field (say year and month) and still have a valid Date or Time. I'm not sure how I'd deal with blank data; perhaps it would be best to hide or ignore the date field if its unpublished. If you come up with a better solution, let me know.
Date: 2006-05-31 10:30 Sender: Joel Stein Thanks, Sean. I like using that option on some models, because it means something. For instance, I have a newsletters, and if the published_on is null, it's a draft, but when it's published, that field gets filled with a date object. Probably not the best way of doing things, but that's how I do it. :)
Date: 2006-05-31 09:41 Sender: Sean Cribbs I have not implemented :include_blank, and I was under the impression that it was not used by the datetime helpers -- partly because having a blank field in a date has no meaning (and could possibly break things!). I'll double check that and get back to you.