Php Codeigniter:set_select()表单验证生日选择器jquery插件
有人能帮我弄清楚如何在中使用Php Codeigniter:set_select()表单验证生日选择器jquery插件,php,jquery,codeigniter,Php,Jquery,Codeigniter,有人能帮我弄清楚如何在中使用set\u select()Form助手吗?我想要的是,如果验证失败,那么在页面加载后,所选的月份、日期和年份将保持不变。假设代码需要被注入到选项中,只有下拉列表是 <?php echo set_select('birth[month]', 'here is the value but it is dynamically generated by the plugin','the condition for update function in the fut
set\u select()
Form助手吗?我想要的是,如果验证失败,那么在页面加载后,所选的月份、日期和年份将保持不变。假设代码需要被注入到选项中,只有下拉列表是
<?php echo set_select('birth[month]', 'here is the value but it is dynamically generated by the plugin','the condition for update function in the future'); ?>
是由jquery生成的
注意:我对月份、日期和年份有问题。如果我只能算出月份,那么其他下拉列表就很容易了。每个月的天数也不同
如果除此插件之外还有其他选择,请随时发表评论
set\u select
是生成选择的帮助程序,它会在呈现视图之前运行,当然,jquery会在之后初始化
你不能在这里使用它,你必须让插件自己处理选择框
根据插件的文档页面,您可以在初始化插件时设置“defaultDate”。我的建议是在初始化插件(javascript)时这样做:
在实际使用之前,您可能需要检查
date
的值,我很快就做到了。我猜这个插件中的defaultDate选项只在控制台中运行。我试了你的建议。我在这把小提琴上做了一些测试:结果证明,格式不是我想象中的YYYY-MM-DD,而是MM-DD-YYYY。尝试更改格式,看看会发生什么,但defaultDate确实有效。感谢您的帮助:)我更新了我的插件,因为新的修复程序是关于defaultDate的。现在它起作用了。
<?php echo set_select('birth[month]', 'here is the value but it is dynamically generated by the plugin','the condition for update function in the future'); ?>
set_select
'var date = '.$this->input->post("year").'-'.$this->input->post("month").'-'.$this->input->post("day").';
$("#demo").birthdayPicker({
defaultDate: date,
});'