Quellcode durchsuchen

added widget option for date and dateRange filters

Pat Haggerty vor 13 Jahren
Ursprung
Commit
f366f2bd56
3 geänderte Dateien mit 10 neuen und 5 gelöschten Zeilen
  1. 7 2
      Form/Type/DateRangeType.php
  2. 2 2
      Form/Type/Filter/DateRangeType.php
  3. 1 1
      Form/Type/Filter/DateType.php

+ 7 - 2
Form/Type/DateRangeType.php

@@ -28,8 +28,13 @@ class DateRangeType extends AbstractType
 
 
     public function buildForm(FormBuilder $builder, array $options)
     public function buildForm(FormBuilder $builder, array $options)
     {
     {
-        $builder->add('start', 'date', array('required' => false));
-        $builder->add('end', 'date', array('required' => false));
+        $builder->add('start', 'date', array_merge(array('required' => false), $options['field_options']));
+        $builder->add('end', 'date', array_merge(array('required' => false), $options['field_options']));
+    }
+
+    public function getDefaultOptions(array $options)
+    {
+        return $options;
     }
     }
     
     
     public function getName()
     public function getName()

+ 2 - 2
Form/Type/Filter/DateRangeType.php

@@ -47,10 +47,10 @@ class DateRangeType extends AbstractType
         $choices = array(
         $choices = array(
             self::TYPE_RANGE            => $this->translator->trans('label_date_type_range', array(), 'SonataAdminBundle'),
             self::TYPE_RANGE            => $this->translator->trans('label_date_type_range', array(), 'SonataAdminBundle'),
         );
         );
-
+        
         $builder
         $builder
             ->add('type', 'choice', array('choices' => $choices, 'required' => false))
             ->add('type', 'choice', array('choices' => $choices, 'required' => false))
-            ->add('value', 'sonata_type_date_range', array('required' => false))
+            ->add('value', 'sonata_type_date_range', array('field_options' => array_merge(array('format' => 'yyyy-MM-dd'), $options['field_options'])))
         ;
         ;
     }
     }
 
 

+ 1 - 1
Form/Type/Filter/DateType.php

@@ -69,7 +69,7 @@ class DateType extends AbstractType
 
 
         $builder
         $builder
             ->add('type', 'choice', array('choices' => $choices, 'required' => false))
             ->add('type', 'choice', array('choices' => $choices, 'required' => false))
-            ->add('value', 'date', array('required' => false))
+            ->add('value', 'date', array_merge(array('required' => false, 'format' => 'yyyy-MM-dd'), $options['field_options']))
         ;
         ;
     }
     }