getSetting('DefaultToToday')) ? $this->getSetting('DefaultToToday') : false; $label = _t('EditableFormField.DEFAULTTOTODAY', 'Default to Today?'); return new FieldSet( new CheckboxField($this->getSettingName("DefaultToToday"), $label, $default) ); } function populateFromPostData($data) { $fieldPrefix = 'Default-'; if(empty($data['Default']) && !empty($data[$fieldPrefix.'Year']) && !empty($data[$fieldPrefix.'Month']) && !empty($data[$fieldPrefix.'Day'])) { $data['Default'] = $data['Year'] . '-' . $data['Month'] . '-' . $data['Day']; } parent::populateFromPostData($data); } /** * Return the form field. * * @todo Make a jQuery safe form field. The current CalendarDropDown * breaks on the front end. */ public function getFormField() { // scripts for jquery date picker Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.core.js'); Requirements::javascript(THIRDPARTY_DIR .'/jquery-ui/jquery.ui.datepicker.js'); $dateFormat = DateField_View_JQuery::convert_iso_to_jquery_format(i18n::get_date_format()); Requirements::customScript(<<getSetting('DefaultToToday')) ? date('d/m/Y') : $this->Default; return new DateField( $this->Name, $this->Title, $default); } /** * Return the validation information related to this field. This is * interrupted as a JSON object for validate plugin and used in the * PHP. * * @see http://docs.jquery.com/Plugins/Validation/Methods * @return Array */ public function getValidation() { return array( 'date' => true ); } }