我正在尝试创建一个自定义日期小部件。用户只能选择接下来 10 天内的日期。因此,我不想让他们选择年、月、日、小时和分钟,而是希望有一个日期(接下来 10 天)的选择列表和两个时间(小时和分钟)的选择列表。
这是我想要实现的目标:
http://i52.tinypic.com/jikrv7.png
这不仅仅是更改日期字段设置(如粒度),我很确定我必须编写一些代码才能在选择列表中包含正确的日期(距离当前月份可能有 5 天,距离下一个月还有 5 天),然后正确处理用户提交数据后的所有事情。
实现这一目标的最佳方法是什么?我应该从哪里开始?
我将非常感谢任何建议。
谢谢你!
I'm trying to create a custom date widget. Users can only chose a date from the next 10 days. So, instead of making them chose year, month, day, hours and minutes I want to have a single select list for the date (next 10 days) and two select lists for the time (hours and minutes).
Here is what I'm trying to achieve:
http://i52.tinypic.com/jikrv7.png
This is not just about changing date field settings (like granularity), I'm pretty sure I'll have to write some code to have correct dates in the select list (there could be 5 days from the current month and 5 days from the next one), and then correctly handle everything after user submits data.
What's the best way to achieve this? Where should I start from?
I would greatly appreciate any suggestions.
Thank you!
发布评论
评论(1)
您需要实施 hook_widget 并可能hook_widget_info 和 hook_widget_settings。另请参阅面向开发人员的 CCK。
You need to implement hook_widget and possibly hook_widget_info and hook_widget_settings. Also have a look at CCK for developers.