【发布时间】:2016-07-22 05:25:03
【问题描述】:
我新开发的 Joomla 组件。我想知道如何在我的 Joomla 组件中添加时间选择器。
【问题讨论】:
我新开发的 Joomla 组件。我想知道如何在我的 Joomla 组件中添加时间选择器。
【问题讨论】:
您可以在 Joomla 中创建自己的自定义字段类型。此示例适用于模块,但相同的过程适用于组件:
创建这个文件:
/modules/mod_yourmodule/fields/datetime.php
<?php // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Add CSS and JS JHtml::stylesheet('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css'); JHtml::stylesheet('http://tarruda.github.com/bootstrap-datetimepicker/assets/css/bootstrap-datetimepicker.min.css');JHtml::script('http://tarruda.github.com/bootstrap-datetimepicker/assets/js/bootstrap-datetimepicker.min.js'); jimport('joomla.form.formfield'); class JFormFieldDateTime extends JFormField {
protected $type = 'DateTime';
public function getInput() {
return '<div class="well">'.
'<div id="datetimepicker2" class="input-append">'.
'<input data-format="MM/dd/yyyy HH:mm:ss PP" type="text"></input>'.
'<span class="add-on">'.
'<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>'.
'</span>'.
'</div>'.
'</div>'.
'<script type="text/javascript">'.
'jQuery(function() {'.
'jQuery("#datetimepicker2").datetimepicker({'.
'language: "en",'.
'pick12HourFormat: true'.
'});'.
'});'.
'</script>';
} }
【讨论】:
显示日历控件字段:
calendar($value, $name, $id, $format= '%Y-%m-%d', $attribs=null)
$value=>The date value,$name=>The name of the text field,$id=>The id of the text field,$format=>'%Y-%m-%d' The date format,$attribs=>null Additional html attributes,$value=>The date value,$name=> The name of the text field,$id=> The id of the text field,$format=>'%Y-%m-%d' The date format,$attribs=>null Additional html attributes
【讨论】: