From cb145a00943882436b4f3e5774c99b5cadb62543 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 27 Jun 2012 10:12:42 +0200 Subject: [PATCH] "dmyplaceholders" setting for DateFields --- forms/DateField.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/forms/DateField.php b/forms/DateField.php index 4df3dec24ca..ea564f0400c 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -16,6 +16,7 @@ * CAUTION: Might not be useable in combination with 'showcalendar', depending on the used javascript library * - 'dmyseparator' (string): HTML markup to separate day, month and year fields. * Only applicable with 'dmyfields'=TRUE. Use 'dateformat' to influence date representation with 'dmyfields'=FALSE. + * - 'dmyplaceholders': Show HTML5 placehoder text to allow identification of the three separate input fields * - 'dateformat' (string): Date format compatible with Zend_Date. * Usually set to default format for {@link locale} through {@link Zend_Locale_Format::getDateFormat()}. * - 'datavalueformat' (string): Internal ISO format string used by {@link dataValue()} to save the @@ -64,6 +65,7 @@ class DateField extends TextField { 'jslocale' => null, 'dmyfields' => false, 'dmyseparator' => ' / ', + 'dmyplaceholders' => true, 'dateformat' => null, 'datavalueformat' => 'yyyy-MM-dd', 'min' => null, @@ -144,15 +146,21 @@ function Field($properties = array()) { $valArr = ($this->valueObj) ? $this->valueObj->toArray() : null; // fields - $fieldDay = new NumericField($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null); - $fieldDay->addExtraClass('day'); - $fieldDay->setMaxLength(2); - $fieldMonth = new NumericField($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null); - $fieldMonth->addExtraClass('month'); - $fieldMonth->setMaxLength(2); - $fieldYear = new NumericField($this->name . '[year]', false, ($valArr) ? $valArr['year'] : null); - $fieldYear->addExtraClass('year'); - $fieldYear->setMaxLength(4); + $fieldNames = Zend_Locale::getTranslationList('Field', $this->locale); + $fieldDay = NumericField::create($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null) + ->addExtraClass('day') + ->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['day'] : null) + ->setMaxLength(2); + + $fieldMonth = NumericField::create($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null) + ->addExtraClass('month') + ->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['month'] : null) + ->setMaxLength(2); + + $fieldYear = NumericField::create($this->name . '[year]', false, ($valArr) ? $valArr['year'] : null) + ->addExtraClass('year') + ->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['year'] : null) + ->setMaxLength(4); // order fields depending on format $sep = $this->getConfig('dmyseparator');