2008-10-03 00:05:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class BasicFieldsTestPage extends TestPage {
|
|
|
|
static $db = array(
|
|
|
|
'Checkbox' => 'Boolean',
|
|
|
|
'Readonly' => 'Varchar',
|
|
|
|
'Textarea' => 'Text',
|
|
|
|
'Text' => 'Varchar',
|
|
|
|
'CalendarDate' => 'Date',
|
|
|
|
'CompositeDate' => 'Date',
|
|
|
|
'Date' => 'Date',
|
2008-10-03 00:38:34 +02:00
|
|
|
"DateDisabled" => "Date",
|
2010-07-12 09:12:47 +02:00
|
|
|
'TimeDisabled' => 'Time',
|
|
|
|
'DateTimeDisabled' => 'Datetime',
|
2008-10-03 00:05:45 +02:00
|
|
|
'DMYCalendarDate' => 'Date',
|
|
|
|
'DMYDate' => 'Date',
|
2010-07-10 04:30:23 +02:00
|
|
|
'DateTime' => 'Datetime',
|
|
|
|
'DateTimeWithCalendar' => 'Datetime',
|
2008-10-03 00:05:45 +02:00
|
|
|
'Time' => 'Time',
|
2010-07-10 04:30:23 +02:00
|
|
|
'TimeWithDropdown' => 'Time',
|
2008-10-03 00:05:45 +02:00
|
|
|
'Number' => 'Int',
|
|
|
|
'Price' => 'Double',
|
|
|
|
'Email' => 'Varchar',
|
|
|
|
'Password' => 'Varchar',
|
|
|
|
'ConfirmedPassword' => 'Varchar',
|
|
|
|
'HTMLField' => 'HTMLText',
|
|
|
|
'HTMLOneLine' => 'HTMLVarchar',
|
|
|
|
'UniqueText' => 'Varchar',
|
|
|
|
'AjaxUniqueText' => 'Varchar',
|
|
|
|
'UniqueRestrictedText' => 'Varchar',
|
|
|
|
'BankNumber' => 'Varchar',
|
|
|
|
'PhoneNumber' => 'Varchar',
|
|
|
|
'Autocomplete' => 'Varchar',
|
|
|
|
'CreditCard' => 'Varchar',
|
|
|
|
'GSTNumber' => 'Varchar',
|
|
|
|
);
|
|
|
|
|
|
|
|
static $has_one = array(
|
|
|
|
'Dropdown' => 'TestCategory',
|
|
|
|
'OptionSet' => 'TestCategory',
|
|
|
|
'GroupedDropdown' => 'TestCategory',
|
|
|
|
'ListboxField' => 'TestCategory',
|
|
|
|
'File' => 'File',
|
2012-02-29 14:27:36 +01:00
|
|
|
'Image' => 'Image',
|
|
|
|
);
|
|
|
|
|
|
|
|
static $has_many = array(
|
|
|
|
'HasManyFiles' => 'File',
|
|
|
|
);
|
|
|
|
|
|
|
|
static $many_many = array(
|
|
|
|
'ManyManyFiles' => 'File',
|
2008-10-03 00:05:45 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
static $defaults = array(
|
|
|
|
'Readonly' => 'Default value for \'readonly\'',
|
2008-10-03 00:38:34 +02:00
|
|
|
"DateDisabled" => "2002-10-23",
|
2010-07-12 09:12:47 +02:00
|
|
|
"DateTimeDisabled" => "2002-10-23 23:59",
|
|
|
|
"TimeDisabled" => "23:59",
|
2008-10-03 00:05:45 +02:00
|
|
|
);
|
|
|
|
|
2012-04-13 15:59:19 +02:00
|
|
|
function getCMSFields() {
|
2008-10-03 00:05:45 +02:00
|
|
|
$fields = parent::getCMSFields();
|
2008-10-06 08:50:10 +02:00
|
|
|
|
2012-02-29 14:27:36 +01:00
|
|
|
$fields->addFieldsToTab('Root.Text', array(
|
2008-10-03 00:05:45 +02:00
|
|
|
new ReadonlyField('Readonly', 'ReadonlyField'),
|
|
|
|
new TextareaField('Textarea', 'TextareaField - 8 rows', 8),
|
|
|
|
new TextField('Text', 'TextField'),
|
2008-10-06 08:50:10 +02:00
|
|
|
new HtmlEditorField('HTMLField', 'HtmlEditorField'),
|
2008-10-03 00:05:45 +02:00
|
|
|
new EmailField('Email', 'EmailField'),
|
|
|
|
new PasswordField('Password', 'PasswordField'),
|
2010-01-26 05:35:45 +01:00
|
|
|
new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage'),
|
2008-10-06 08:50:10 +02:00
|
|
|
));
|
|
|
|
|
2012-02-29 14:27:36 +01:00
|
|
|
$fields->addFieldsToTab('Root.Numeric', array(
|
2008-10-06 08:50:10 +02:00
|
|
|
new NumericField('Number', 'NumericField'),
|
2010-04-12 07:27:50 +02:00
|
|
|
new CurrencyField('Price', 'CurrencyField'),
|
2008-10-03 00:05:45 +02:00
|
|
|
new PhoneNumberField('PhoneNumber', 'PhoneNumberField'),
|
2010-01-26 04:40:12 +01:00
|
|
|
new CreditCardField('CreditCard', 'CreditCardField')
|
2008-10-03 00:05:45 +02:00
|
|
|
));
|
2008-10-06 08:50:10 +02:00
|
|
|
|
2012-02-29 14:27:36 +01:00
|
|
|
$fields->addFieldsToTab('Root.Option', array(
|
2008-10-06 08:50:10 +02:00
|
|
|
new CheckboxField('Checkbox', 'CheckboxField'),
|
2012-02-29 14:27:36 +01:00
|
|
|
new CheckboxSetField('CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
2008-10-06 08:50:10 +02:00
|
|
|
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()),
|
|
|
|
));
|
2008-10-03 00:05:45 +02:00
|
|
|
|
2010-01-26 05:35:45 +01:00
|
|
|
// All these date/time fields generally have issues saving directly in the CMS
|
2012-02-29 14:27:36 +01:00
|
|
|
$fields->addFieldsToTab('Root.DateTime', array(
|
2010-07-10 04:30:23 +02:00
|
|
|
$calendarDateField = new DateField('CalendarDate','DateField with calendar'),
|
2008-10-03 00:05:45 +02:00
|
|
|
new DateField('Date','DateField'),
|
2010-07-10 04:30:23 +02:00
|
|
|
$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')
|
2010-01-27 02:40:18 +01:00
|
|
|
));
|
2010-07-10 04:30:23 +02:00
|
|
|
$calendarDateField->setConfig('showcalendar', true);
|
|
|
|
$dmyDateField->setConfig('dmyfields', true);
|
|
|
|
$timeFieldDropdown->setConfig('showdropdown', true);
|
|
|
|
$dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
|
|
|
|
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
2008-10-03 00:05:45 +02:00
|
|
|
|
2012-02-29 14:27:36 +01:00
|
|
|
$fields->addFieldsToTab('Root.File', array(
|
2012-04-12 11:56:25 +02:00
|
|
|
UploadField::create('File','FileUploadField'),
|
|
|
|
UploadField::create('Image','ImageUploadField'),
|
|
|
|
UploadField::create('HasManyFiles','HasManyFilesUploadField'),
|
|
|
|
UploadField::create('ManyManyFiles','ManyManyFilesUploadField')
|
2008-10-03 00:05:45 +02:00
|
|
|
));
|
2008-11-13 22:32:37 +01:00
|
|
|
|
2012-02-29 14:39:11 +01:00
|
|
|
$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) {
|
2012-11-30 12:08:46 +01:00
|
|
|
$field
|
|
|
|
->setDescription('This is <strong>bold</strong> help text')
|
|
|
|
->addExtraClass('cms-help');
|
|
|
|
// ->addExtraClass('cms-help cms-help-tooltip');
|
|
|
|
|
2012-02-29 14:39:11 +01:00
|
|
|
$disabledField = $field->performDisabledTransformation();
|
|
|
|
$disabledField->setTitle($disabledField->Title() . ' (disabled)');
|
2012-03-02 01:03:02 +01:00
|
|
|
$disabledField->setName($disabledField->getName() . '_disabled');
|
|
|
|
$tabObj->insertAfter($disabledField, $field->getName());
|
2012-02-29 14:39:11 +01:00
|
|
|
|
|
|
|
$readonlyField = $field->performReadonlyTransformation();
|
|
|
|
$readonlyField->setTitle($readonlyField->Title() . ' (readonly)');
|
2012-03-02 01:03:02 +01:00
|
|
|
$readonlyField->setName($readonlyField->getName() . '_readonly');
|
|
|
|
$tabObj->insertAfter($readonlyField, $field->getName());
|
2012-02-29 14:39:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-08 10:36:12 +01:00
|
|
|
$fields->addFieldToTab('Root.Text', new TextField('Text_NoLabel', false, 'TextField without label'), 'Text_disabled');
|
|
|
|
|
2008-10-03 00:05:45 +02:00
|
|
|
return $fields;
|
2008-11-13 22:32:37 +01:00
|
|
|
|
2008-10-03 00:05:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BasicFieldsTestPage_Controller extends TestPage_Controller {
|
|
|
|
function AutoCompleteItems() {
|
|
|
|
$items = array(
|
|
|
|
'TestItem1',
|
|
|
|
'TestItem2',
|
|
|
|
'TestItem3',
|
|
|
|
'TestItem4',
|
|
|
|
);
|
|
|
|
return implode(',', $items);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-03 00:38:34 +02:00
|
|
|
?>
|