Skip to content

Commit

Permalink
[ISSUE-7] Date placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Teixeira committed Apr 16, 2013
1 parent b97add7 commit a83b346
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
18 changes: 17 additions & 1 deletion Grid/Filter/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<input ' . $this->getNameAndId() . ' type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->container->getParameter('pedro_teixeira_grid.date.date_format')) . '">';
$html = '<input ' . $this->getNameAndId() . ' type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->dateFormat) . '">';
$html .= '<script type="text/javascript">$(document).ready(function () {$("#' . $this->getId() . '").datepicker()})</script>';
} else {
$html = '<input ' . $this->getNameAndId() . ' type="date" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '">';
Expand Down
4 changes: 2 additions & 2 deletions Grid/Filter/DateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function render()
{
if ($this->getUseDatePicker()) {

$html = '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'from" type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->container->getParameter('pedro_teixeira_grid.date.date_format')) . '">';
$html = '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'from" type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->dateFormat) . '">';
$html .= $this->getInputSeparator();
$html .= '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'to" type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->container->getParameter('pedro_teixeira_grid.date.date_format')) . '">';
$html .= '<input class="date-input" name="' . $this->getIndex() . '[]" id="' . $this->getId() . 'to" type="text" value="' . $this->getValue() . '" placeholder="' . $this->getPlaceholder() . '" data-date-format="' . strtolower($this->dateFormat) . '">';
$html .= '<script type="text/javascript">$(document).ready(function () {$("#' . $this->getId() . 'from").datepicker(); $("#' . $this->getId() . 'to").datepicker()})</script>';

} else {
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/css/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

.pedroteixeira-grid-wrapper table thead tr th .date-input {
width: 70px;
width: 75px;
}

.pedroteixeira-grid-wrapper table tfoot #pagination {
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/less/grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
width: auto;
}
.date-input {
width: 70px;
width: 75px;
}
}
}
Expand Down

0 comments on commit a83b346

Please sign in to comment.