Silverstripe 如何通过自定义表单模板在日期字段上使用日历?

发布于 2024-12-23 03:58:31 字数 435 浏览 4 评论 0原文

我按照说明 这里

但是,我在向日历添加日期字段时遇到问题。通常我只是做这样的事情:

$dateField = new DateField ('DateRequired', 'Date Required');
$dateField->setConfig ('showcalendar', true);

我已经在自定义表单中尝试了上述代码,但是该页面不包含日历字段的任何 jquery ui 脚本或 css 文件。

所以我的问题是如何让我的自定义表单包含所有脚本并使用 jquery ui 日历呈现字段?

I have created a custom form class and template for my form by following the instructions here.

However I am having trouble with adding DateFields with calendars. Usually I just do something like this:

$dateField = new DateField ('DateRequired', 'Date Required');
$dateField->setConfig ('showcalendar', true);

I have tried the above code in my custom form however the page doesn't include any of the jquery ui scripts or css files for the calendar field.

So my question is how can I get the my custom form to include all the scripts and render the fields with the jquery ui calendars?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁人与我共长歌 2024-12-30 03:58:31

实际上模板的改变是没有必要的。

$dateField = new DateField('...');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('showdropdown', true);
$dateField->setConfig('dateformat', 'dd.MM.YYYY');

actually the change of the template should not be necessary.

$dateField = new DateField('...');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('showdropdown', true);
$dateField->setConfig('dateformat', 'dd.MM.YYYY');
-黛色若梦 2024-12-30 03:58:31

好吧,我已经解决了。模板中调用字段的代码需要从: 更改

$dataFieldByName(DateRequired)

为:

$dataFieldByName(DateRequired).FieldHolder

现在所有 javascript 都包含在页面中。

Ok I have worked it out. The code within the template that calls the fields needs to be changed from:

$dataFieldByName(DateRequired)

to:

$dataFieldByName(DateRequired).FieldHolder

Now all of the javascript is included within the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文