@@ -99,8 +99,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
9999 $ childOptions = array ();
100100 foreach ($ this ->timeParts as $ part ) {
101101 if ($ options ['with_ ' .$ part ]) {
102- $ childOptions [$ part ] = array ();
103- $ childOptions [$ part ]['error_bubbling ' ] = true ;
102+ $ childOptions [$ part ] = array (
103+ 'error_bubbling ' => true ,
104+ 'label ' => $ options ['labels ' ][$ part ],
105+ );
104106 if ('choice ' === $ options ['widget ' ]) {
105107 $ childOptions [$ part ]['choice_translation_domain ' ] = false ;
106108 $ childOptions [$ part ]['choices ' ] = $ options [$ part ];
@@ -131,6 +133,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
131133 }
132134 if ($ options ['with_invert ' ]) {
133135 $ builder ->add ('invert ' , 'Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , array (
136+ 'label ' => $ options ['labels ' ]['invert ' ],
134137 'error_bubbling ' => true ,
135138 'required ' => false ,
136139 'translation_domain ' => $ options ['translation_domain ' ],
@@ -192,6 +195,21 @@ public function configureOptions(OptionsResolver $resolver)
192195 return array_fill_keys ($ timeParts , $ placeholder );
193196 };
194197
198+ $ labelsNormalizer = function (Options $ options , array $ labels ) {
199+ return array_replace (array (
200+ 'years ' => null ,
201+ 'months ' => null ,
202+ 'days ' => null ,
203+ 'weeks ' => null ,
204+ 'hours ' => null ,
205+ 'minutes ' => null ,
206+ 'seconds ' => null ,
207+ 'invert ' => 'Negative interval ' ,
208+ ), array_filter ($ labels , function ($ label ) {
209+ return null !== $ label ;
210+ }));
211+ };
212+
195213 $ resolver ->setDefaults (
196214 array (
197215 'with_years ' => true ,
@@ -220,9 +238,11 @@ public function configureOptions(OptionsResolver $resolver)
220238 // this option.
221239 'data_class ' => null ,
222240 'compound ' => $ compound ,
241+ 'labels ' => array (),
223242 )
224243 );
225244 $ resolver ->setNormalizer ('placeholder ' , $ placeholderNormalizer );
245+ $ resolver ->setNormalizer ('labels ' , $ labelsNormalizer );
226246
227247 $ resolver ->setAllowedValues (
228248 'input ' ,
@@ -260,6 +280,7 @@ public function configureOptions(OptionsResolver $resolver)
260280 $ resolver ->setAllowedTypes ('with_minutes ' , 'bool ' );
261281 $ resolver ->setAllowedTypes ('with_seconds ' , 'bool ' );
262282 $ resolver ->setAllowedTypes ('with_invert ' , 'bool ' );
283+ $ resolver ->setAllowedTypes ('labels ' , 'array ' );
263284 }
264285
265286 /**
0 commit comments