Grocery CRUD日期输入的默认值? [英] Default value of Grocery CRUD date input?

查看:146
本文介绍了Grocery CRUD日期输入的默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循Grocery CRUD网络文档中的指南 http://www.grocerycrud.com/examples/callback_edit_field_example

i follow the guide in Grocery CRUD web documentation http://www.grocerycrud.com/examples/callback_edit_field_example

我想这是在插入时为输入字段设置默认值的方法之一。我试图使用相同的方法设置日期输入字段的默认值。日期值出现在字段中,但它的jquery日期选择器功能不再可用。

i guess this is one of the ways to set default value for your input field when insert. I am trying to set the default value for date input field by using the same method. The date value did appear in the field but it the jquery date picker function is not available anymore.

有没有人尝试在Grocery CRUD中设置日期的默认值,但仍保留其jquery datepicker函数?

did any one tried to set the default value for date in Grocery CRUD but still remain its jquery datepicker function ?

感谢高级!

推荐答案

在添加输入页面时,我正在查找输入表单中显示的默认日期值。我对您的示例进行了一些更改

I am looking for default date value appear in the input form when in the add input page. I made some changes on your example

$crud = new grocery_CRUD();
....

if( $crud->getState() == 'add' ) { //add these only in add form
    $crud->set_css('assets/grocery_crud/css/ui/simple/'.grocery_CRUD::JQUERY_UI_CSS);
    $crud->set_js('assets/grocery_crud/js/jquery_plugins/config/jquery.datepicker.config.js');
}

$crud->callback_add_field('date',array($this,'_add_default_date_value'));

....
$output = $crud->render();

function _add_default_date_value(){
        $value = !empty($value) ? $value : date("d/m/Y");
        $return = '<input type="text" name="date" value="'.$value.'" class="datepicker-input" /> ';
        $return .= '<a class="datepicker-input-clear" tabindex="-1">Clear</a> (dd/mm/yyyy)';
        return $return;
}

这篇关于Grocery CRUD日期输入的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆