Skip to content
This repository
Browse code

"dmyplaceholders" setting for DateFields

  • Loading branch information...
commit cb145a00943882436b4f3e5774c99b5cadb62543 1 parent 81c085f
Ingo Schommer authored June 27, 2012

Showing 1 changed file with 17 additions and 9 deletions. Show diff stats Hide diff stats

  1. 26  forms/DateField.php
26  forms/DateField.php
@@ -16,6 +16,7 @@
16 16
  *    CAUTION: Might not be useable in combination with 'showcalendar', depending on the used javascript library
17 17
  * - 'dmyseparator' (string): HTML markup to separate day, month and year fields.
18 18
  *    Only applicable with 'dmyfields'=TRUE. Use 'dateformat' to influence date representation with 'dmyfields'=FALSE.
  19
+ * - 'dmyplaceholders': Show HTML5 placehoder text to allow identification of the three separate input fields
19 20
  * - 'dateformat' (string): Date format compatible with Zend_Date.
20 21
  *    Usually set to default format for {@link locale} through {@link Zend_Locale_Format::getDateFormat()}.
21 22
  * - 'datavalueformat' (string): Internal ISO format string used by {@link dataValue()} to save the
@@ -64,6 +65,7 @@ class DateField extends TextField {
64 65
 		'jslocale' => null,
65 66
 		'dmyfields' => false,
66 67
 		'dmyseparator' => '&nbsp;<span class="separator">/</span>&nbsp;',
  68
+		'dmyplaceholders' => true,
67 69
 		'dateformat' => null,
68 70
 		'datavalueformat' => 'yyyy-MM-dd',
69 71
 		'min' => null,
@@ -144,15 +146,21 @@ function Field($properties = array()) {
144 146
 			$valArr = ($this->valueObj) ? $this->valueObj->toArray() : null;
145 147
 
146 148
 			// fields
147  
-			$fieldDay = new NumericField($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null);
148  
-			$fieldDay->addExtraClass('day');
149  
-			$fieldDay->setMaxLength(2);
150  
-			$fieldMonth = new NumericField($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null);
151  
-			$fieldMonth->addExtraClass('month');
152  
-			$fieldMonth->setMaxLength(2);
153  
-			$fieldYear = new NumericField($this->name . '[year]', false, ($valArr) ? $valArr['year'] : null);
154  
-			$fieldYear->addExtraClass('year');
155  
-			$fieldYear->setMaxLength(4);
  149
+			$fieldNames = Zend_Locale::getTranslationList('Field', $this->locale);
  150
+			$fieldDay = NumericField::create($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null)
  151
+				->addExtraClass('day')
  152
+				->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['day'] : null)
  153
+				->setMaxLength(2);
  154
+
  155
+			$fieldMonth = NumericField::create($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null)
  156
+				->addExtraClass('month')
  157
+				->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['month'] : null)
  158
+				->setMaxLength(2);
  159
+			
  160
+			$fieldYear = NumericField::create($this->name . '[year]', false, ($valArr) ? $valArr['year'] : null)
  161
+				->addExtraClass('year')
  162
+				->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['year'] : null)
  163
+				->setMaxLength(4);
156 164
 			
157 165
 			// order fields depending on format
158 166
 			$sep = $this->getConfig('dmyseparator');

0 notes on commit cb145a0

Please sign in to comment.
Something went wrong with that request. Please try again.