Octobercms动态设置日期选择器minDate [英] Octobercms set dynamically datepicker minDate
本文介绍了Octobercms动态设置日期选择器minDate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要动态设置
public function filterFields($fields, $context = null)
{
$return_date = $fields->return_date->value;
if(empty($return_date)) {
$fields->return_date->minDate = Carbon::now();
}
}
不行!
推荐答案
您应注意模型的fields.yaml
-在主选项卡或辅助选项卡中的return_date
字段定义位置?
You should pay attention to your model's fields.yaml
- Where have you defined the return_date
field, is it in the primary or secondary tabs ?
尝试:
public function formExtendFieldsBefore( $widget ) {
$widget->tabs['fields']['return_date']['minDate'] = Carbon::now()->format('Y-m-d');
}
或
public function formExtendFieldsBefore( $widget ) {
$widget->secondaryTabs['fields']['return_date']['minDate'] = Carbon::now()->format('Y-m-d');
// notice here $widget->secondaryTabs Vs $widget->tabs
}
这应该可以,如果不行,请共享您的fields.yaml
文件.
This should work, if it doesn't please share your fields.yaml
file .
这篇关于Octobercms动态设置日期选择器minDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文