"dmyplaceholders" setting for DateFields

This commit is contained in:
Ingo Schommer 2012-06-27 10:12:42 +02:00
parent 81c085f777
commit cb145a0094

View File

@ -16,6 +16,7 @@ require_once 'Zend/Date.php';
* CAUTION: Might not be useable in combination with 'showcalendar', depending on the used javascript library * 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. * - '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. * 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. * - 'dateformat' (string): Date format compatible with Zend_Date.
* Usually set to default format for {@link locale} through {@link Zend_Locale_Format::getDateFormat()}. * 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 * - 'datavalueformat' (string): Internal ISO format string used by {@link dataValue()} to save the
@ -64,6 +65,7 @@ class DateField extends TextField {
'jslocale' => null, 'jslocale' => null,
'dmyfields' => false, 'dmyfields' => false,
'dmyseparator' => '&nbsp;<span class="separator">/</span>&nbsp;', 'dmyseparator' => '&nbsp;<span class="separator">/</span>&nbsp;',
'dmyplaceholders' => true,
'dateformat' => null, 'dateformat' => null,
'datavalueformat' => 'yyyy-MM-dd', 'datavalueformat' => 'yyyy-MM-dd',
'min' => null, 'min' => null,
@ -144,15 +146,21 @@ class DateField extends TextField {
$valArr = ($this->valueObj) ? $this->valueObj->toArray() : null; $valArr = ($this->valueObj) ? $this->valueObj->toArray() : null;
// fields // fields
$fieldDay = new NumericField($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null); $fieldNames = Zend_Locale::getTranslationList('Field', $this->locale);
$fieldDay->addExtraClass('day'); $fieldDay = NumericField::create($this->name . '[day]', false, ($valArr) ? $valArr['day'] : null)
$fieldDay->setMaxLength(2); ->addExtraClass('day')
$fieldMonth = new NumericField($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null); ->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['day'] : null)
$fieldMonth->addExtraClass('month'); ->setMaxLength(2);
$fieldMonth->setMaxLength(2);
$fieldYear = new NumericField($this->name . '[year]', false, ($valArr) ? $valArr['year'] : null); $fieldMonth = NumericField::create($this->name . '[month]', false, ($valArr) ? $valArr['month'] : null)
$fieldYear->addExtraClass('year'); ->addExtraClass('month')
$fieldYear->setMaxLength(4); ->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 // order fields depending on format
$sep = $this->getConfig('dmyseparator'); $sep = $this->getConfig('dmyseparator');