public function testOverrideWithNull() { $field = new TimeField('Time', 'Time'); $field->setValue('11:00pm'); $field->setValue(''); $this->assertEquals($field->dataValue(), ''); }
public function getCMSFields() { //Fetch curret fields and store in Fields $fields = parent::getCMSFields(); //Remove Fields $fields->removeFieldFromTab("Root.Main", array("SortOrder", "CalendarID", "Title", "Content", "StartDate", "StartTime", "EndDate", "EndTime", "Location")); //Event Title $Title = new TextField("Title", "Event Title"); $Title->setRightTitle("Enter the event title. i.e. sports day."); //Start Date & Time $StartDate = new DateField("StartDate", "Start Date"); $StartDate->setConfig('showcalendar', 1); $StartDate->setConfig('dateformat', 'dd/MM/YYYY'); $StartTime = new TimeField("StartTime", "Start Time (Optional)"); $StartTime->setConfig('use_strtotime', 1); //End Date & Time $EndDate = new DateField("EndDate", "End Date (Optional)"); $EndDate->setConfig('showcalendar', 1); $EndDate->setConfig('dateformat', 'dd/MM/YYYY'); $EndTime = new TimeField("EndTime", "End Time (Optional)"); $StartTime->setConfig('use_strtotime', 1); //Location $Location = new AddressTextField("Location", "Event Location", "AIzaSyA-folYpPWGiFcpBZURJpf610nO6FJtqqQ"); $Location->SetRightTitle("Optional. Begin typing and you will see address suggestions (Beta). Powered by Google."); $Location->addExtraClass("text"); //Event Description $Description = new HTMLEditorField("Content", "Event Description"); //Group Start and End Date & Time Fields $Times = FieldGroup::create($StartDate, $StartTime, $EndDate, $EndTime)->setTitle('Timings'); //Add Fields to the CMS $fields->addFieldsToTab("Root.Main", array($Title, $Times, $Location, $Description)); //Return Fields to the CMS return $fields; }
function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Text', array(new ReadonlyField('Readonly', 'ReadonlyField'), new TextareaField('Textarea', 'TextareaField - 8 rows', 8), new TextField('Text', 'TextField'), new HtmlEditorField('HTMLField', 'HtmlEditorField'), new EmailField('Email', 'EmailField'), new PasswordField('Password', 'PasswordField'), new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage'))); $fields->addFieldsToTab('Root.Numeric', array(new NumericField('Number', 'NumericField'), new CurrencyField('Price', 'CurrencyField'), new PhoneNumberField('PhoneNumber', 'PhoneNumberField'), new CreditCardField('CreditCard', 'CreditCardField'))); $fields->addFieldsToTab('Root.Option', array(new CheckboxField('Checkbox', 'CheckboxField'), new CheckboxSetField('CheckboxSet', 'CheckboxSetField', TestCategory::map()), new DropdownField('DropdownID', 'DropdownField', TestCategory::map()), new GroupedDropdownField('GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())), new ListboxField('ListboxFieldID', 'ListboxField', TestCategory::map(), array(), 3), new OptionsetField('OptionSetID', 'OptionSetField', TestCategory::map()))); // All these date/time fields generally have issues saving directly in the CMS $fields->addFieldsToTab('Root.DateTime', array($calendarDateField = new DateField('CalendarDate', 'DateField with calendar'), new DateField('Date', 'DateField'), $dmyDateField = new DateField('DMYDate', 'DateField with separate fields'), new TimeField('Time', 'TimeField'), $timeFieldDropdown = new TimeField('TimeDropdown', 'TimeField with dropdown'), new DatetimeField('DateTime', 'DateTime'), $dateTimeShowCalendar = new DatetimeField('DateTimeWithCalendar', 'DateTime with calendar'))); $calendarDateField->setConfig('showcalendar', true); $dmyDateField->setConfig('dmyfields', true); $timeFieldDropdown->setConfig('showdropdown', true); $dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true); $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true); $fields->addFieldsToTab('Root.File', array(UploadField::create('File', 'FileUploadField'), UploadField::create('Image', 'ImageUploadField'), UploadField::create('HasManyFiles', 'HasManyFilesUploadField'), UploadField::create('ManyManyFiles', 'ManyManyFilesUploadField'))); $tabs = array('Root.Text', 'Root.Numeric', 'Root.Option', 'Root.DateTime', 'Root.File'); foreach ($tabs as $tab) { $tabObj = $fields->fieldByName($tab); foreach ($tabObj->FieldList() as $field) { $disabledField = $field->performDisabledTransformation(); $disabledField->setTitle($disabledField->Title() . ' (disabled)'); $disabledField->setName($disabledField->getName() . '_disabled'); $tabObj->insertAfter($disabledField, $field->getName()); $readonlyField = $field->performReadonlyTransformation(); $readonlyField->setTitle($readonlyField->Title() . ' (readonly)'); $readonlyField->setName($readonlyField->getName() . '_readonly'); $tabObj->insertAfter($readonlyField, $field->getName()); } } $fields->addFieldToTab('Root.Text', new TextField('Text_NoLabel', false, 'TextField without label'), 'Text_disabled'); return $fields; }
public function scaffoldFormField($title = null, $params = null) { $field = TimeField::create($this->name, $title); // Show formatting hints for better usability $field->setDescription(sprintf(_t('FormField.Example', 'e.g. %s', 'Example format'), Convert::raw2xml(Zend_Date::now()->toString($field->getConfig('timeformat'))))); $field->setAttribute('placeholder', $field->getConfig('timeformat')); return $field; }
public function fetchDataModification($value) { list($date, $time) = explode(' ', $value); $date = DateField::fetchDataModification($date); $time = TimeField::fetchDataModification($time); $value = $date . ' ' . $time; return $value; }
function Field($properties = array()) { $this->addExtraClass('timepicker')->setAttribute('autocomplete', 'off')->setAttribute('data-jqueryuiconfig', Convert::array2json($this->timePickerConfig)); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/jquery.ui.timepicker.js'); Requirements::javascript(TIMEPICKERFIELD_MODULE . '/javascript/timepickerfield.js'); Requirements::css(TIMEPICKERFIELD_MODULE . '/css/jquery.ui.timepicker.css'); return parent::Field($properties); }
function Field() { self::Requirements(); $field = parent::Field(); $id = $this->id(); $val = $this->attrValue(); $innerHTML = self::HTMLField($id, $this->name, $val); return <<<HTML \t\t\t<div class="dropdowntime"> \t\t\t\t{$innerHTML} \t\t\t</div> HTML; }
public function getFormField() { switch ($this->Type) { case 'datetime': $field = new DatetimeField($this->getFormFieldName(), $this->Title); $field->getDateField()->setConfig('showcalendar', true); $field->getTimeField()->setConfig('showdropdown', true); break; case 'date': $field = new DateField($this->getFormFieldName(), $this->Title); $field->setConfig('showcalendar', true); break; case 'time': $field = new TimeField($this->getFormFieldName(), $this->Title); $field->setConfig('showdropdown', true); break; } if ($this->DefaultType == 'created') { $field->setRightTitle('The value will default to the time this record was created.'); } return $field; }
public function __toString() { $languages = c::get('languages'); $lang = $currentLang = strtoupper(site()->language()->code()); foreach ($languages as $l) { if (isset($l['default']) && $l['default']) { $lang = strtoupper($l['code']); } } if ($currentLang == $lang) { return parent::__toString(); } return ""; }
public function getCMSFields() { $startdatefield = new DateField('StartDate', 'Start Date'); $startdatefield->setConfig('showcalendar', true); $startdatefield->setConfig('dateformat', 'MM/dd/yyyy'); $enddatefield = new DateField('EndDate', 'End Date'); $enddatefield->setConfig('showcalendar', true); $enddatefield->setConfig('dateformat', 'MM/dd/yyyy'); $imagefield = UploadField::create('Photo'); $imagefield->folderName = 'Calendar'; $imagefield->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); $resourcefield = UploadField::create('Resource')->setTitle('Flyer/Brochure (PDF or Doc)'); $resourcefield->folderName = 'Calendar'; $resourcefield->getValidator()->allowedExtensions = array('pdf', 'doc', 'docx'); return new FieldList(TextField::create('Title'), $startdatefield, $enddatefield, TimeField::create('StartTime')->setTitle('Start Time'), TimeField::create('EndTime')->setTitle('End Time'), TextField::create('Location'), $imagefield, $resourcefield, HTMLEditorField::create('Content')->setTitle('Event Description')); }
/** * @todo This should be generated by JavaScript, but we don't have the date libraries' */ function Field($properties = array()) { $this->addExtraClass('timedropdownfield'); $html = parent::Field($properties); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript('timedropdownfield/javascript/TimeDropdownField.js'); Requirements::css('timedropdownfield/css/TimeDropdownField.css'); $iteratedTime = new Zend_Date('00:00:00', 'h:mm:ss'); $options = array(); $count = 24 * (60 / $this->config['interval']); for ($i = 0; $i < $count; $i++) { $key = $iteratedTime->toString($this->getConfig('datavalueformat')); $options[$key] = $iteratedTime->toString($this->getConfig('timeformat')); $iteratedTime->add($this->config['interval'], Zend_Date::MINUTE); } $dropdownField = new DropdownField('dropdown_' . $this->getName(), false, $options, $this->Value()); $dropdownField->addExtraClass('presets'); $dropdownField->setHasEmptyDefault(true); $dropdownField->setForm($this->getForm()); $html .= $dropdownField->Field(); $html .= '<a href="#" class="presets-trigger"></a>'; return $html; }
function jsValidation() { return $this->dateField->jsValidation() . $this->timeField->jsValidation(); }
/** * Test that AM/PM is preserved correctly in various situations */ public function testPreserveAMPM() { // Test with timeformat that includes hour // Check pm $f = new TimeField('Time', 'Time'); $f->setConfig('timeformat', 'h:mm:ss a'); $f->setValue('3:59 pm'); $this->assertEquals($f->dataValue(), '15:59:00'); // Check am $f = new TimeField('Time', 'Time'); $f->setConfig('timeformat', 'h:mm:ss a'); $f->setValue('3:59 am'); $this->assertEquals($f->dataValue(), '03:59:00'); // Check with ISO date/time $f = new TimeField('Time', 'Time'); $f->setConfig('timeformat', 'h:mm:ss a'); $f->setValue('15:59:00'); $this->assertEquals($f->dataValue(), '15:59:00'); // ISO am $f = new TimeField('Time', 'Time'); $f->setConfig('timeformat', 'h:mm:ss a'); $f->setValue('03:59:00'); $this->assertEquals($f->dataValue(), '03:59:00'); }
private function Fields() { return FieldList::create(TextField::create('Title'), TextField::create('Subtitle'), CheckboxField::create("IsTrue"), CheckboxSetField::create('CheckboxSet', 'Options', array('Opt1' => 'Opt1', 'Opt2' => 'Opt2', 'Opt3' => 'Opt3', 'Opt4' => 'Opt4', 'Opt5' => 'Opt5')), DropdownField::create('DDP', 'Choose an item', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'))->setEmptyString('(Select one)'), GroupedDropdownField::create('DDP2', 'Choose an item', array('Group1' => array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'Group2' => array('ITEM6' => 'Item 6', 'ITEM7' => 'Item 7', 'ITEM8' => 'Item 8', 'ITEM9' => 'Item 9', 'ITEM0' => 'Item 0')))->setEmptyString('(Select one)'), ListboxField::create('lbf', 'Choose items', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3'), LookupField::create('lf', 'Look up field', array('ITEM1' => 'Item 1', 'ITEM2' => 'Item 2', 'ITEM3' => 'Item 3', 'ITEM4' => 'Item 4', 'ITEM5' => 'Item 5'), 'ITEM3')->setEmptyString('(Select one)'), NullableField::create(TextField::create("nf", "Field 1", "abc")), NullableField::create(CheckBoxField::create("nf2", "Field 1", "abc")), NumericField::create("nf3", "NumericField", 10), NumericField_Readonly::create('NFR1', 'NumericField_Readonly'), OptionsetField::create($name = "op", $title = "OptionsetField", $source = array("1" => "Option 1", "2" => "Option 2", "3" => "Option 3", "4" => "Option 4", "5" => "Option 5"), $value = "3"), ReadonlyField::create('rf1', 'read only field', 'value'), TextareaField::create($name = "description", $title = "Description", $value = "This is the default description"), DateField::create('datefield', 'Date Field')->setConfig('showcalendar', true), TimeField::create('timeField', 'Time Field', '12am')); }
/** * @expectedException \RuntimeException */ public function testTimeFieldGetDataNotWorking() { $t = new TimeField(); $t->getData(); }
function __construct($name, $title = null, $value = "") { parent::__construct($name, $title, $value); }
function validate($validator) { $dateValid = $this->dateField->validate($validator); $timeValid = $this->timeField->validate($validator); return $dateValid && $timeValid; }
/** * Frontend fields * Simple list of the basic fields - how they're intended to be edited */ function getFrontEndFields($params = null) { //parent::getFrontEndFields($params); $timeFrameHeaderText = 'Time Frame'; if (!CalendarConfig::subpackage_setting('events', 'force_end')) { $timeFrameHeaderText = 'End Date / Time (optional)'; } $fields = FieldList::create(TextField::create('Title')->setAttribute('placeholder', 'Enter a title'), CheckboxField::create('AllDay', 'All-day'), $startDateTime = DatetimeField::create('StartDateTime', 'Start'), CheckboxField::create('NoEnd', 'Open End'), HeaderField::create('TimeFrameHeader', $timeFrameHeaderText, 5), SelectionGroup::create('TimeFrameType', array("Duration//Duration" => TimeField::create('Duration', '')->setRightTitle('up to 24h')->setAttribute('placeholder', 'Enter duration'), "DateTime//Date/Time" => $endDateTime = DateTimeField::create('EndDateTime', ''))), LiteralField::create('Clear', '<div class="clear"></div>')); //Date field settings $timeExpl = 'Time, e.g. 11:15am or 15:30'; //$startDateTime->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm'); //$endDateTime->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm'); $startDateTime->getDateField()->setConfig('showcalendar', 1)->setAttribute('placeholder', 'Enter date')->setAttribute('readonly', 'true'); //we only want input through the datepicker $startDateTime->getTimeField()->setConfig('timeformat', 'HH:mm')->setAttribute('placeholder', 'Enter time'); $endDateTime->getDateField()->setConfig('showcalendar', 1)->setAttribute('placeholder', 'Enter date')->setAttribute('readonly', 'true'); //we only want input through the datepicker $endDateTime->getTimeField()->setConfig('timeformat', 'HH:mm')->setAttribute('placeholder', 'Enter time'); //removing AllDay checkbox if allday events are disabled if (!CalendarConfig::subpackage_setting('events', 'enable_allday_events')) { $fields->removeByName('AllDay'); } //removing NoEnd checkbox if end dates are enforced if (CalendarConfig::subpackage_setting('events', 'force_end')) { $fields->removeByName('NoEnd'); } else { //we don't want the NoEnd checkbox when creating new events if (!$this->ID) { //$fields->removeByName('NoEnd'); } } $this->extend('updateFrontEndFields', $fields); return $fields; }
/** * @ignore * * @param array $opts * * @return TimeField */ public static function TimeField($opts = []) { return TimeField::createObject($opts); }
/** * FormHandler::timeField() * * Create a timeField on the form * * @param string $title: The title of the field * @param string $name: The name of the field * @param string $validator: The validator which should be used to validate the value of the field * @param int $format: 12 or 24. Which should we use? * @param string $extra: CSS, Javascript or other which are inserted into the HTML tag * @return void * @access public * @author Teye Heimans */ function timeField($title, $name, $validator = null, $required = null, $format = null, $extra = null) { require_once FH_INCLUDE_DIR . 'fields/class.SelectField.php'; require_once FH_INCLUDE_DIR . 'fields/class.TimeField.php'; // create a new timefield $fld = new TimeField($this, $name); if (!empty($validator)) { $fld->setValidator($validator); } if (!is_null($required)) { $fld->setRequired($required); } if (!empty($format)) { $fld->setHourFormat($format); } if (!empty($extra)) { $fld->setExtra($extra); } // register the field $this->_registerField($name, $fld, $title); }
/** * If no time set then return either the default value if set or the configured empty value. * @return string */ public function dataValue() { return parent::dataValue() ?: ($this->defaultValue ?: $this->config()->get('empty_value')); }
public function getAttributes() { return array_merge(parent::getAttributes(), array('type' => 'time', 'step' => $this->interval)); }
/** * @param TField $field * @param bool $showMultipleFields */ protected function configureTimeField(TField $field, $showMultipleFields = true) { if ($showMultipleFields) { // if not set then the default will be used for the locale if ($format = $this->config()->get('time_field_format')) { $field->setConfig('timeformat', $format); } } }