|
@@ -18,7 +18,31 @@ use Symfony\Component\Form\ValueTransformer\DateTimeToArrayTransformer;
|
|
|
use Symfony\Component\Form\ValueTransformer\ValueTransformerChain;
|
|
|
|
|
|
/**
|
|
|
- * A field for editing a date and a time simultaneously
|
|
|
+ * A field for editing a date and a time simultaneously.
|
|
|
+ *
|
|
|
+ * Available options:
|
|
|
+ *
|
|
|
+ * * date_widget: How to render the date field ("input" or "choice"). Default: "choice".
|
|
|
+ * * time_widget: How to render the time field ("input" or "choice"). Default: "choice".
|
|
|
+ * * type: The type of the date stored on the object. Default: "datetime":
|
|
|
+ * * datetime: A DateTime object;
|
|
|
+ * * string: A raw string (e.g. 2011-05-01 12:30:00, Y-m-d H:i:s);
|
|
|
+ * * timestamp: A unix timestamp (e.g. 1304208000).
|
|
|
+ * * date_pattern: The pattern for the select boxes when date "widget" is "choice".
|
|
|
+ * You can use the placeholders "{{ year }}", "{{ month }}" and "{{ day }}".
|
|
|
+ * Default: locale dependent.
|
|
|
+ * * with_seconds Whether or not to create a field for seconds. Default: false.
|
|
|
+ *
|
|
|
+ * * years: An array of years for the year select tag.
|
|
|
+ * * months: An array of months for the month select tag.
|
|
|
+ * * days: An array of days for the day select tag.
|
|
|
+ * * hours: An array of hours for the hour select tag.
|
|
|
+ * * minutes: An array of minutes for the minute select tag.
|
|
|
+ * * seconds: An array of seconds for the second select tag.
|
|
|
+ *
|
|
|
+ * * date_format: The date format type to use for displaying the date. Default: medium.
|
|
|
+ * * data_timezone: The timezone of the data. Default: UTC.
|
|
|
+ * * user_timezone: The timezone of the user entering a new value. Default: UTC.
|
|
|
*
|
|
|
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
|
|
|
*/
|
|
@@ -51,24 +75,24 @@ class DateTimeField extends FieldGroup
|
|
|
TimeField::INPUT,
|
|
|
);
|
|
|
|
|
|
- /**
|
|
|
- * {@inheritDoc}
|
|
|
- */
|
|
|
- public function configure()
|
|
|
+ protected function configure()
|
|
|
{
|
|
|
+ $this->addOption('date_widget', DateField::CHOICE, self::$dateWidgets);
|
|
|
+ $this->addOption('time_widget', TimeField::CHOICE, self::$timeWidgets);
|
|
|
+ $this->addOption('type', self::DATETIME, self::$types);
|
|
|
+ $this->addOption('date_pattern');
|
|
|
+ $this->addOption('with_seconds', false);
|
|
|
+
|
|
|
$this->addOption('years', range(date('Y') - 5, date('Y') + 5));
|
|
|
$this->addOption('months', range(1, 12));
|
|
|
$this->addOption('days', range(1, 31));
|
|
|
$this->addOption('hours', range(0, 23));
|
|
|
$this->addOption('minutes', range(0, 59));
|
|
|
$this->addOption('seconds', range(0, 59));
|
|
|
+
|
|
|
$this->addOption('data_timezone', 'UTC');
|
|
|
$this->addOption('user_timezone', 'UTC');
|
|
|
$this->addOption('date_format', DateField::MEDIUM, self::$dateFormats);
|
|
|
- $this->addOption('date_widget', DateField::CHOICE, self::$dateWidgets);
|
|
|
- $this->addOption('time_widget', TimeField::CHOICE, self::$timeWidgets);
|
|
|
- $this->addOption('type', self::DATETIME, self::$types);
|
|
|
- $this->addOption('with_seconds', false);
|
|
|
|
|
|
$this->add(new DateField('date', array(
|
|
|
'type' => DateField::RAW,
|
|
@@ -79,6 +103,7 @@ class DateTimeField extends FieldGroup
|
|
|
'years' => $this->getOption('years'),
|
|
|
'months' => $this->getOption('months'),
|
|
|
'days' => $this->getOption('days'),
|
|
|
+ 'pattern' => $this->getOption('date_pattern'),
|
|
|
)));
|
|
|
$this->add(new TimeField('time', array(
|
|
|
'type' => TimeField::RAW,
|