/** * Defines and build a date picker. * According to the parameter elem, it will set the element. * * $params['exclude'] => boolean; defines if the column is built. * $params['required '] => boolean; * $params['elem'] => select, checkbox, radio, editor; * If $params['elem'] = select, then the $params['src'] * parameter must be defined. * $params['src'] => string; name of the source for the element. * * @param array $meta * @param array $params * * @return void */ public function setElementDatepicker(array $meta, array $params) { $date = new Cible_Form_Element_DatePicker($this->_elemNameId, array('jquery.params' => array('changeYear' => true, 'changeMonth' => true, 'yearRange' => '-25:+10', 'altField' => '#' . $this->_elemNameId . 'Dt', 'altFormat' => 'yy-mm-dd', 'dateFormat' => 'dd-mm-yy', 'defaultDate' => "\$('#" . $this->_elemNameId . "').val()", 'YearOrdering' => 'desc'))); $date->setLabel($this->getView()->getCibleText('form_label_' . $this->_elemNameId)); if (!$meta['NULLABLE']) { $date->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field')))); } if (!empty($params['validate'])) { $date->addValidator('Date', true, array('messages' => array('dateNotYYYY-MM-DD' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateInvalid' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateFalseFormat' => $this->getView()->getCibleText('validation_message_invalid_date')))); } $params['elem'] = 'hidden'; $params['class'] = ''; $meta['COLUMN_NAME'] = $meta['COLUMN_NAME'] . 'Dt'; $this->setElementInput($meta, $params); $date = $this->_setBasicDecorator($date); $this->addElement($date); }
/** * Add a date picker element to the form. * * @see Cible_Form_Element_DatePicker * * @param array $question * * @return void */ private function _addDate($question) { $elemName = $question['FQT_TypeName'] . self::UNDERSCORE . $question['FQ_ElementID']; $options['jquery.params'] = array('changeYear' => true, 'changeMonth' => true); $element = new Cible_Form_Element_DatePicker($elemName, $options); $element->addValidator('Date', true, array('format' => 'dd-mm-yy', 'messages' => array('dateNotYYYY-MM-DD' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateInvalid' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateFalseFormat' => $this->getView()->getCibleText('validation_message_invalid_date')))); $element->removeDecorator('DtDdWrapper'); $element->addDecorators(array('UiWidgetElement', array('HtmlTag', array('tag' => 'div', 'class' => 'answer-zone')))); $element->setAttrib('class', 'dateTextInput'); $element->setjQueryParam('dateFormat', 'dd-mm-yy'); $this->_addExtras($element, $question); $this->addElement($element); $this->_displayGroupElements[] = $elemName; }