@@ -26,10 +26,17 @@ class JqueryDatePickerType extends AbstractType
2626{
2727 public function buildForm (FormBuilderInterface $ builder , array $ options )
2828 {
29- $ format_php = $ options ['format ' ];
29+ $ formatPhp = $ options ['format ' ];
30+ if ($ options ['time_format ' ]) {
31+ if ($ options ['input ' ] !== 'datetime ' ) {
32+ throw new InvalidConfigurationException ('The time_format is compatible only with input = datetime ' );
33+ }
34+
35+ $ formatPhp = \sprintf ('%s %s ' , $ formatPhp , $ options ['time_format ' ]);
36+ }
3037
3138 $ builder ->addViewTransformer (
32- new DateTimeToStringTransformer ($ options ['data_timezone ' ], $ options ['user_timezone ' ], $ format_php )
39+ new DateTimeToStringTransformer ($ options ['data_timezone ' ], $ options ['user_timezone ' ], $ formatPhp )
3340 );
3441
3542 if ($ options ['input ' ] === 'string ' ) {
@@ -79,6 +86,15 @@ public function buildView(FormView $view, FormInterface $form, array $options)
7986 $ view ->vars ['go_to_current ' ] = ($ options ['go_to_current ' ]) ? 'true ' : 'false ' ;
8087 $ view ->vars ['number_of_months ' ] = $ options ['number_of_months ' ];
8188 $ view ->vars ['other ' ] = $ options ['other ' ];
89+
90+ $ view ->vars ['time_format ' ] = null ;
91+ $ phpTimeFormat = $ options ['time_format ' ];
92+ if ($ phpTimeFormat ) {
93+ $ phpTimes = array ('a ' , 'A ' , 'g ' , 'G ' , 'h ' , 'H ' , 'i ' , 's ' , 'u ' , 'v ' );
94+ $ jqueryTimes = array ('t ' , 'T ' , 'h ' , 'H ' , 'hh ' , 'HH ' , 'mm ' ,'ss ' , 's ' , 'c ' , 'l ' );
95+
96+ $ view ->vars ['time_format ' ] = str_replace ($ phpTimes , $ jqueryTimes , $ phpTimeFormat );
97+ }
8298 }
8399
84100
@@ -93,6 +109,7 @@ public function configureOptions(OptionsResolver $resolver)
93109 array (
94110 'input ' => 'datetime ' ,
95111 'format ' => 'd/m/Y ' ,
112+ 'time_format ' => null ,
96113 'data_timezone ' => null ,
97114 'user_timezone ' => null ,
98115 'change_month ' => true ,
0 commit comments