| 1 |
#sfJQueryDateTimePickerPlugin# |
|---|
| 2 |
|
|---|
| 3 |
A plugin using juqery TimePicker library to provide a dropdown of time based on specification of intervals and start and stop times. |
|---|
| 4 |
|
|---|
| 5 |
The most recent version of this plugin includes a validator class which can be used to bind value based on a datetime format. |
|---|
| 6 |
|
|---|
| 7 |
The version of the plugin also comes with javascript and css assets for the time picker. |
|---|
| 8 |
|
|---|
| 9 |
## Installation ## |
|---|
| 10 |
|
|---|
| 11 |
* Install jQuery (http://www.jquery.com) somewhere under your web folder (preferably under web/js). |
|---|
| 12 |
|
|---|
| 13 |
* Install jQuery-UI (http://www.jqueryui.com) somewhere under your web folder (preferably under web/js). |
|---|
| 14 |
|
|---|
| 15 |
* Install Datejs (http://www.datejs.com) somewhere under your web folder (preferably under web/js). |
|---|
| 16 |
|
|---|
| 17 |
* Add the jQuery, timePicker, jQuery-UI and Datejs JavaScript files to the javascripts list in your application's config/view.yml file. |
|---|
| 18 |
|
|---|
| 19 |
* Add any CSS files you want to use for timePicker and datePicker, and add them to the stylesheets list in view.yml. |
|---|
| 20 |
|
|---|
| 21 |
[php] |
|---|
| 22 |
stylesheets: [ ... , /sfJQueryDateTimeFormWidgetPlugin/css/timePicker.css, ... ] |
|---|
| 23 |
|
|---|
| 24 |
javascripts: [ ... , /sfJQueryDateTimeFormWidgetPlugin/js/jquery.timePicker.js, ... ] |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
* Install the plugin. |
|---|
| 28 |
Using symfony command line: |
|---|
| 29 |
./symfony plugin:install sfJQueryTimeDateFormWidgetPlugin |
|---|
| 30 |
Or get the latest version from the subversion repository: |
|---|
| 31 |
svn co http://svn.symfony-project.com/plugins/sfJQueryTimeDateFormWidgetPlugin plugins/sfJQueryTimeDateFormWidgetPlugin |
|---|
| 32 |
|
|---|
| 33 |
* If you installed by subversion, activate the plugin in the config/ProjectConfiguration.class.php file (this will have already been done automatically if you used the plugin:install symfony command). |
|---|
| 34 |
|
|---|
| 35 |
[php] |
|---|
| 36 |
class ProjectConfiguration extends sfProjectConfiguration |
|---|
| 37 |
{ |
|---|
| 38 |
public function setup() |
|---|
| 39 |
{ |
|---|
| 40 |
... |
|---|
| 41 |
$this->enablePlugins('sfJQueryTimeDateFormWidgetPlugin'); |
|---|
| 42 |
... |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
* Publish the Assets. |
|---|
| 47 |
Using symfony command line: |
|---|
| 48 |
./symfony plugin:publish-assets |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
## How to use ## |
|---|
| 52 |
|
|---|
| 53 |
* Edit a form, for example lib/form/doctrine/MyForm.class.php. To use the date component, do something like this: |
|---|
| 54 |
|
|---|
| 55 |
[php] |
|---|
| 56 |
$params = $this->getOption('params'); |
|---|
| 57 |
|
|---|
| 58 |
$options = array( |
|---|
| 59 |
'widget_name'=>'time', |
|---|
| 60 |
'params'=>$params, |
|---|
| 61 |
'default_date'=>date('Y-m-d'), |
|---|
| 62 |
'default_time'=>date('h:i A') |
|---|
| 63 |
); |
|---|
| 64 |
|
|---|
| 65 |
$this->setWidget('time',new sfJQueryDateTimeWidget($options)); |
|---|
| 66 |
$this->setValidator('time', new sfJQueryDateTimeValidator(array('widget_name'=>'time'))); |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
* Clear your cache. |
|---|
| 70 |
./symfony cc |
|---|
| 71 |
|
|---|
| 72 |
* Test your form. |
|---|
| 73 |
|
|---|
| 74 |
## Widget Options ## |
|---|
| 75 |
|
|---|
| 76 |
* widget_name (string) |
|---|
| 77 |
the name of the widget |
|---|
| 78 |
* time_interval (string) |
|---|
| 79 |
a number from one to 60 to minumize minute selection |
|---|
| 80 |
* params (array) |
|---|
| 81 |
an array of form request data |
|---|
| 82 |
* default_date (string) |
|---|
| 83 |
the default date for the date picker in YYYY-mm-dd |
|---|
| 84 |
* default_time (string) |
|---|
| 85 |
the default time for the time picker in hh:ii AA |
|---|
| 86 |
* time_start_stop (array) |
|---|
| 87 |
an array with two keys: |
|---|
| 88 |
* start (string) |
|---|
| 89 |
the start time of the time picker in HH.MM |
|---|
| 90 |
* stop (string) |
|---|
| 91 |
the stop time of the time picker in HH.MM |
|---|
| 92 |
* time_image (string) |
|---|
| 93 |
a path to an image to display as the time picker button |
|---|
| 94 |
|
|---|
| 95 |
## Validator Options ## |
|---|
| 96 |
|
|---|
| 97 |
* widget_name (string): The name of the widget (to retrieve specific input value) |
|---|
| 98 |
* date_format (string): The format to use when submitting a date with time (default to Y-m-d h:i A) |
|---|
| 99 |
* with_time (string): true if the validator must return a time, false otherwise |
|---|
| 100 |
* date_output (string): The format to use when returning a date (default to Y-m-d) |
|---|
| 101 |
* datetime_output (string): The format to use when returning a date with time (default to Y-m-d H:i:s) |
|---|
| 102 |
|
|---|