Skip to content

Commit

Permalink
[Form] Allow setting the date_format option via DateTimeField
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and Bernhard Schussek committed Jan 19, 2011
1 parent ae40a5d commit 5995772
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Symfony/Component/Form/DateTimeField.php
Expand Up @@ -34,6 +34,13 @@ class DateTimeField extends FieldGroup
self::TIMESTAMP,
);

protected static $dateFormats = array(
DateField::FULL,
DateField::LONG,
DateField::MEDIUM,
DateField::SHORT,
);

protected static $dateWidgets = array(
DateField::CHOICE,
DateField::INPUT,
Expand All @@ -57,6 +64,7 @@ public function configure()
$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);
Expand All @@ -65,6 +73,7 @@ public function configure()
$this->add(new DateField('date', array(
'type' => DateField::RAW,
'widget' => $this->getOption('date_widget'),
'format' => $this->getOption('date_format'),
'data_timezone' => $this->getOption('user_timezone'),
'user_timezone' => $this->getOption('user_timezone'),
'years' => $this->getOption('years'),
Expand Down

0 comments on commit 5995772

Please sign in to comment.