From a83b3467aabf6bc84a3aeb27f739e0b8fb923ed5 Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 16 Apr 2013 13:02:09 +0200 Subject: [PATCH] [ISSUE-7] Date placeholder --- Grid/Filter/Date.php | 18 +++++++++++++++++- Grid/Filter/DateRange.php | 4 ++-- Resources/public/css/grid.css | 2 +- Resources/public/less/grid.less | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Grid/Filter/Date.php b/Grid/Filter/Date.php index a6d492d..168bca6 100644 --- a/Grid/Filter/Date.php +++ b/Grid/Filter/Date.php @@ -12,13 +12,29 @@ class Date extends FilterAbstract */ protected $operatorType = 'date'; + /** + * @var string + */ + protected $dateFormat; + + /** + * @param \Symfony\Component\DependencyInjection\Container $container + */ + public function __construct(\Symfony\Component\DependencyInjection\Container $container) + { + parent::__construct($container); + + $this->dateFormat = $this->container->getParameter('pedro_teixeira_grid.date.date_format'); + $this->setPlaceholder(strtoupper($this->dateFormat)); + } + /** * @return string */ public function render() { if ($this->getUseDatePicker()) { - $html = 'getNameAndId() . ' type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->container->getParameter('pedro_teixeira_grid.date.date_format')) . '">'; + $html = 'getNameAndId() . ' type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->dateFormat) . '">'; $html .= ''; } else { $html = 'getNameAndId() . ' type="date" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '">'; diff --git a/Grid/Filter/DateRange.php b/Grid/Filter/DateRange.php index 42c8bb4..1e37db5 100644 --- a/Grid/Filter/DateRange.php +++ b/Grid/Filter/DateRange.php @@ -24,9 +24,9 @@ public function render() { if ($this->getUseDatePicker()) { - $html = ''; + $html = ''; $html .= $this->getInputSeparator(); - $html .= ''; + $html .= ''; $html .= ''; } else { diff --git a/Resources/public/css/grid.css b/Resources/public/css/grid.css index 7d545f1..6615d57 100644 --- a/Resources/public/css/grid.css +++ b/Resources/public/css/grid.css @@ -30,7 +30,7 @@ } .pedroteixeira-grid-wrapper table thead tr th .date-input { - width: 70px; + width: 75px; } .pedroteixeira-grid-wrapper table tfoot #pagination { diff --git a/Resources/public/less/grid.less b/Resources/public/less/grid.less index d9f6b52..0e5c345 100644 --- a/Resources/public/less/grid.less +++ b/Resources/public/less/grid.less @@ -25,7 +25,7 @@ width: auto; } .date-input { - width: 70px; + width: 75px; } } }