本文整理汇总了PHP中GridField::create方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField::create方法的具体用法?PHP GridField::create怎么用?PHP GridField::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField
的用法示例。
在下文中一共展示了GridField::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldsToTab("Root.Banners", GridField::create("Banners", null, $this->owner->Banners(), $config = GridFieldConfig_RecordEditor::create()));
if (class_exists("GridFieldOrderableRows")) {
$config->addComponent(new GridFieldOrderableRows());
}
}
示例2: getCMSFields
public function getCMSFields()
{
$self = $this;
$this->beforeUpdateCMSFields(function ($f) use($self) {
Requirements::javascript('event_calendar/javascript/calendar_cms.js');
$f->addFieldToTab("Root.Main", TextField::create("Location", _t('Calendar.LOCATIONDESCRIPTION', 'The location for this event')), 'Content');
$dt = _t('CalendarEvent.DATESANDTIMES', 'Dates and Times');
$recursion = _t('CalendarEvent.RECURSION', 'Recursion');
$f->addFieldToTab("Root.{$dt}", GridField::create("DateTimes", _t('Calendar.DATETIMEDESCRIPTION', 'Add dates for this event'), $self->DateTimes(), GridFieldConfig_RecordEditor::create()));
$f->addFieldsToTab("Root.{$recursion}", array(new CheckboxField('Recursion', _t('CalendarEvent.REPEATEVENT', 'Repeat this event')), new OptionsetField('CustomRecursionType', _t('CalendarEvent.DESCRIBEINTERVAL', 'Describe the interval at which this event recurs.'), array('1' => _t('CalendarEvent.DAILY', 'Daily'), '2' => _t('CalendarEvent.WEEKLY', 'Weekly'), '3' => _t('CalendarEvent.MONTHLY', 'Monthly')))));
$f->addFieldToTab("Root.{$recursion}", $dailyInterval = new FieldGroup(new LabelField($name = "every1", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('DailyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "days", $title = _t("CalendarEvent.DAYS", " day(s)"))));
$f->addFieldToTab("Root.{$recursion}", $weeklyInterval = new FieldGroup(new LabelField($name = "every2", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('WeeklyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "weeks", $title = _t("CalendarEvent.WEEKS", " weeks"))));
$f->addFieldToTab("Root.{$recursion}", new CheckboxSetField('RecurringDaysOfWeek', _t('CalendarEvent.ONFOLLOWINGDAYS', 'On the following day(s)...'), DataList::create("RecurringDayOfWeek")->map("ID", "Title")));
$f->addFieldToTab("Root.{$recursion}", $monthlyInterval = new FieldGroup(new LabelField($name = "every3", $title = _t("CalendarEvent.EVERY", "Every ")), new DropdownField('MonthlyInterval', '', array_combine(range(1, 10), range(1, 10))), new LabelField($name = "months", $title = _t("CalendarEvent.MONTHS", " month(s)"))));
$f->addFieldsToTab("Root.{$recursion}", array(new OptionsetField('MonthlyRecursionType1', '', array('1' => _t('CalendarEvent.ONTHESEDATES', 'On these date(s)...'))), new CheckboxSetField('RecurringDaysOfMonth', '', DataList::create("RecurringDayOfMonth")->map("ID", "Value")), new OptionsetField('MonthlyRecursionType2', '', array('1' => _t('CalendarEvent.ONTHE', 'On the...')))));
$f->addFieldToTab("Root.{$recursion}", $monthlyIndex = new FieldGroup(new DropdownField('MonthlyIndex', '', array('1' => _t('CalendarEvent.FIRST', 'First'), '2' => _t('CalendarEvent.SECOND', 'Second'), '3' => _t('CalendarEvent.THIRD', 'Third'), '4' => _t('CalendarEvent.FOURTH', 'Fourth'), '5' => _t('CalendarEvent.LAST', 'Last'))), new DropdownField('MonthlyDayOfWeek', '', DataList::create("RecurringDayOfWeek")->map("Value", "Title")), new LabelField($name = "ofthemonth", $title = _t("CalendarEvent.OFTHEMONTH", " of the month."))));
$f->addFieldToTab("Root.{$recursion}", GridField::create("Exceptions", _t('CalendarEvent.ANYEXCEPTIONS', 'Any exceptions to this pattern? Add the dates below.'), $self->Exceptions(), GridFieldConfig_RecordEditor::create()));
$dailyInterval->addExtraClass('dailyinterval');
$weeklyInterval->addExtraClass('weeklyinterval');
$monthlyInterval->addExtraClass('monthlyinterval');
$monthlyIndex->addExtraClass('monthlyindex');
});
$f = parent::getCMSFields();
return $f;
}
示例3: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.EnquiryForm', HeaderField::create('Enquiry Form Setup', 2));
$gridFieldConfig = GridFieldConfig_RecordEditor::create(100);
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
/* Unset field-sorting hack */
$gridFieldConfig->getComponentByType('GridFieldSortableHeader')->setFieldSorting(array('FieldName' => 'FieldNameNoSorting', 'FieldType' => 'FieldTypeNoSorting'));
$gridField = GridField::create('EnquiryFormFields', false, $this->EnquiryFormFields(), $gridFieldConfig);
$fields->addFieldToTab('Root.EnquiryForm', $gridField);
$email_settings = array(EmailField::create('EmailTo', 'Send email to'), EmailField::create('EmailFrom', 'Send email from')->setRightTitle('For example website@yourdomain.com'), TextField::create('EmailSubject', 'Email subject'), HeaderField::create('Message on website once completed', 5), HTMLEditorField::create('EmailSubmitCompletion', '')->setRows(10), EmailField::create('EmailBcc', 'Send BCC copy to (optional)')->setRightTitle('If you would like a copy of the enquiry to be sent elsewhere, fill that in here.'), TextField::create('EmailSubmitButtonText', 'Submit button text'));
$toggleSettings = ToggleCompositeField::create('FormSettings', 'Enquiry Form Settings', $email_settings);
$fields->addFieldsToTab('Root.EnquiryForm', $toggleSettings);
$spam_settings = array();
array_push($spam_settings, DropdownField::create('AddCaptcha', 'Add captcha image (optional)', array(0 => 'No', 1 => 'Yes'))->setRightTitle('You can optionally enable an anti-spam "captcha" image.
This adds a small image with 4 random numbers which needs to be filled in correctly.'));
if (!$this->CaptchaText) {
$this->CaptchaText = 'Verification Image';
}
array_push($spam_settings, TextField::create('CaptchaText', 'Field name'));
array_push($spam_settings, TextField::create('CaptchaHelp', 'Captcha help (optional)')->setRightTitle('If you would like to explain what the captcha is, please explain briefly what it is.
This is only used if you have selected to add the captcha image.'));
$toggleSpam = ToggleCompositeField::create('SpamSettings', 'Anti-Spam Settings', $spam_settings);
$fields->addFieldsToTab('Root.EnquiryForm', $toggleSpam);
return $fields;
}
示例4: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$fields = $form->Fields();
$title = _t('AssetAdmin.FILES', 'Files');
// File listing
$gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPaginator(self::config()->page_length), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldDetailForm());
$gridField = GridField::create('CloudinaryFile', $title, $this->getList(), $gridFieldConfig);
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('StripThumbnail' => '', 'NameForSummaryField' => _t('File.Name'), 'Created' => _t('AssetAdmin.CREATED', 'Date'), 'getSize' => _t('AssetAdmin.SIZE', 'Size')));
$columns->setFieldCasting(array('Created' => 'Date->Nice'));
$gridField->setAttribute('data-url-folder-template', Controller::join_links($this->Link('show'), '%s'));
if (!$fields->hasTabset()) {
$tabs = new TabSet('Root', $tabList = new Tab('ListView', _t('AssetAdmin.ListView', 'List View')));
$tabList->addExtraClass("content-listview cms-tabset-icon list");
$fields->push($tabs);
}
$uploadBtn = new LiteralField('UploadButton', sprintf('<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="drive-upload" href="%s">%s</a>', Controller::join_links(singleton('CloudinaryFileAddController')->Link()), _t('Folder.UploadFilesButton', 'Upload')));
$actionButtonsComposite = CompositeField::create()->addExtraClass('cms-actions-row');
$actionButtonsComposite->push($uploadBtn);
$fields->addFieldsToTab('Root.ListView', array($actionsComposite = CompositeField::create($actionButtonsComposite)->addExtraClass('cms-content-toolbar field'), $gridField));
$fields->setForm($form);
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$form->addExtraClass('cms-edit-form center ' . $this->BaseCSSClasses());
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
return $form;
}
示例5: getModularCMSFields
function getModularCMSFields($relationName = 'Modules', $title = 'Content Modules')
{
$fields = array();
$GLOBALS['_CONTENT_MODULE_PARENT_PAGEID'] = $this->owner->ID;
$area = $this->owner->obj($relationName);
if ($area && $area->exists()) {
$fields[] = HeaderField::create($relationName . 'Header', $title, 2);
$fields[] = GridField::create($relationName, $title, $area->Modules(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldOrderableRows('SortOrder'))->removeComponentsByType('GridFieldAddNewButton')->addComponent($add = new GridFieldAddNewMultiClass()));
if (($allowed_modules = $this->owner->Config()->get('allowed_modules')) && is_array($allowed_modules) && count($allowed_modules)) {
if (isset($allowed_modules[$relationName])) {
$add->setClasses($allowed_modules[$relationName]);
} else {
$add->setClasses($allowed_modules);
}
} else {
// Remove the base "ContentModule" from allowed modules.
$classes = array_values(ClassInfo::subclassesFor('ContentModule'));
sort($classes);
if (($key = array_search('ContentModule', $classes)) !== false) {
unset($classes[$key]);
}
$add->setClasses($classes);
}
} else {
$fields[] = LiteralField::create('SaveFirstToAddModules', '<div class="message">You must save first before you can add modules.</div>');
}
return $fields;
}
示例6: getFieldEditorGrid
/**
* Gets the field editor, for adding and removing EditableFormFields.
*
* @return GridField
*/
public function getFieldEditorGrid()
{
Requirements::javascript(USERFORMS_DIR . '/javascript/FieldEditor.js');
$fields = $this->Fields();
$editableColumns = new GridFieldEditableColumns();
$fieldClasses = singleton('EditableFormField')->getEditableFieldClasses();
$editableColumns->setDisplayFields(array('ClassName' => function ($record, $column, $grid) use($fieldClasses) {
if ($record instanceof EditableFormField) {
return $record->getInlineClassnameField($column, $fieldClasses);
}
}, 'Title' => function ($record, $column, $grid) {
if ($record instanceof EditableFormField) {
return $record->getInlineTitleField($column);
}
}));
$config = GridFieldConfig::create()->addComponents($editableColumns, new GridFieldButtonRow(), GridFieldAddClassesButton::create('EditableTextField')->setButtonName(_t('UserFormFieldEditorExtension.ADD_FIELD', 'Add Field'))->setButtonClass('ss-ui-action-constructive'), GridFieldAddClassesButton::create('EditableFormStep')->setButtonName(_t('UserFormFieldEditorExtension.ADD_PAGE_BREAK', 'Add Page Break')), GridFieldAddClassesButton::create(array('EditableFieldGroup', 'EditableFieldGroupEnd'))->setButtonName(_t('UserFormFieldEditorExtension.ADD_FIELD_GROUP', 'Add Field Group')), new GridFieldEditButton(), new GridFieldDeleteAction(), new GridFieldToolbarHeader(), new GridFieldDetailForm());
$fieldEditor = GridField::create('Fields', _t('UserDefinedForm.FIELDS', 'Fields'), $fields, $config)->addExtraClass('uf-field-editor');
if (Config::inst()->get('UserFormFieldEditorExtension', 'showAddEdit')) {
$addFieldAction->setTitle(_t('UserFormFieldEditorExtension.ADD_EDIT_FIELD', 'Add & Edit Field'));
$fields = $addFieldAction->getClasses($fieldEditor);
$fields = array_diff_key($fields, array_flip(array('EditableFormStep', 'EditableFieldGroup', 'EditableFieldGroupEnd')));
asort($fields);
$addFieldAction->setClasses($fields);
}
return $fieldEditor;
}
示例7: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
// check if the insertbefore field is present (may be added later, in which case the above
// fields never get added
//$insertOnTab = $this->owner->getFilterableArchiveConfigValue('pagination_control_tab');
//$insertBefore = $this->owner->getFilterableArchiveConfigValue('pagination_insert_before');
$insertOnTab = Config::inst()->get($this->owner->className, 'pagination_control_tab');
$insertBefore = Config::inst()->get($this->owner->className, 'pagination_insert_before');
if (!$fields->fieldByName("{$insertOnTab}.{$insertBefore}")) {
$insertBefore = null;
}
//if($this->owner->getFilterableArchiveConfigValue('datearchive_active')){
if (Config::inst()->get($this->owner->className, 'datearchive_active')) {
//$fields->addFieldToTab($this->owner->getFilterableArchiveConfigValue('pagination_control_tab'),
$fields->addFieldToTab(Config::inst()->get($this->owner->className, 'pagination_control_tab'), DropdownField::create('ArchiveUnit', _t('filterablearchive.ARCHIVEUNIT', 'Archive unit'), array('year' => _t('filterablearchive.YEAR', 'Year'), 'month' => _t('filterablearchive.MONTH', 'Month'), 'day' => _t('filterablearchive.DAY', 'Day'))), $insertBefore);
}
$pagerField = NumericField::create("ItemsPerPage", _t("filterablearchive.ItemsPerPage", "Pagination: items per page"))->setRightTitle(_t("filterablearchive.LeaveEmptyForNone", "Leave empty or '0' for no pagination"));
$fields->addFieldToTab($insertOnTab, $pagerField, $insertBefore);
//
// Create categories and tag config
//
// $config = GridFieldConfig_RecordEditor::create();
// $config->removeComponentsByType("GridFieldAddNewButton");
// $config->addComponent(new GridFieldAddByDBField("buttons-before-left"));
// Lets just use what others have made already...
$config = GridFieldConfig::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldTitleHeader())->addComponent(new GridFieldEditableColumns())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldAddNewInlineButton('toolbar-header-right'));
//if($this->owner->getFilterableArchiveConfigValue('categories_active')){
if (Config::inst()->get($this->owner->className, 'categories_active')) {
$fields->addFieldToTab($insertOnTab, $categories = GridField::create("Categories", _t("FilterableArchive.Categories", "Categories"), $this->owner->Categories(), $config), $insertBefore);
}
//if($this->owner->getFilterableArchiveConfigValue('tags_active')){
if (Config::inst()->get($this->owner->className, 'tags_active')) {
$fields->addFieldToTab($insertOnTab, $tags = GridField::create("Tags", _t("FilterableArchive.Tags", "Tags"), $this->owner->Tags(), $config), $insertBefore);
}
}
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-filterablearchive,代码行数:35,代码来源:FilterableArchiveHolderExtension.php
示例8: getEditForm
public function getEditForm($id = null, $fields = null)
{
// TODO Duplicate record fetching (see parent implementation)
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
// TODO Duplicate record fetching (see parent implementation)
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
$memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
if ($record && method_exists($record, 'getValidator')) {
$validator = $record->getValidator();
} else {
$validator = Injector::inst()->get('Member')->getValidator();
}
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
$groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
$columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
$columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
return Convert::raw2xml($item->getBreadcrumbs(' > '));
}));
$fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the' . ' database')))), $groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
// Add import capabilities. Limit to admin since the import logic can affect assigned permissions
if (Permission::check('ADMIN')) {
$fields->addFieldsToTab('Root.Users', array(new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
$fields->addFieldsToTab('Root.Groups', array(new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
}
// Tab nav in CMS is rendered through separate template
$root->setTemplate('CMSTabSet');
// Add roles editing interface
if (Permission::check('APPLY_ROLES')) {
$rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
$rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
$rolesTab->push($rolesField);
}
$actionParam = $this->getRequest()->param('Action');
if ($actionParam == 'groups') {
$groupsTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'users') {
$usersTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'roles') {
$rolesTab->addExtraClass('ui-state-active');
}
$actions = new FieldList();
$form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// Tab nav in CMS is rendered through separate template
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
return $form;
}
示例9: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab("Root.SocialLinks", GridField::create("SocialLinks", "Social Network Links", $this->owner->SocialLinks(), $config = GridFieldConfig_RelationEditor::create()));
if (class_exists("GridFieldOrderableRows")) {
$config->addComponent(new GridFieldOrderableRows());
}
}
示例10: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
/** @var Page|MapaelCountryHolderPageExtension $page */
$page = $this->getOwner();
$tab = $fields->findOrMakeTab('Root.CountryPagesTab', $page->fieldLabel('CountryPages'));
$tab->push(GridField::create('CountryPages', $page->fieldLabel('CountryPages'), $page->CountryPages(), GridFieldConfig_RelationEditor::create()));
}
示例11: getCMSFields
public function getCMSFields()
{
$fields = new FieldList();
$fields->push(new TabSet("Root", new Tab("Main", TextField::create("Title", "Title"), GridField::create("Slides", "Nivo Slide", $this->Slides(), GridFieldConfig_RecordEditor::create())), new Tab("Advanced", DropdownField::create("Theme", "Theme", self::get_all_themes()), DropdownField::create("Effect", "Effect", $this->dbObject("Effect")->enumValues()), NumericField::create("AnimationSpeed", "Animation Speed")->setDescription("Animation speed in milliseconds."), NumericField::create("PauseTime", "Pause Time")->setDescription("Pause time on each frame in milliseconds."), TextField::create("PrevText", "Previous Text"), TextField::create("NextText", "Next Text"), NumericField::create("Slices", "Slices")->setDescription("Number of slices for slice animation effects."), NumericField::create("BoxCols", "Box Columns")->setDescription("Number of box columns for box animation effects."), NumericField::create("BoxRows", "Box Rows")->setDescription("Number of box rows for box animation effects."), NumericField::create("StartSlide", "Start Slide")->setDescription("Slide to start on (0 being the first)."), HeaderField::create("ControlHeading", "Control Options", 4), CompositeField::create(array(CheckboxField::create("DirectionNav", "Display Direction Navigation?"), CheckboxField::create("ControlNav", "Display Control Navigation?"), CheckboxField::create("ControlNavThumbs", "Use thumbnails for control nav?"), CheckboxField::create("PauseOnHover", "Stop the animation whilst hovering?"), CheckboxField::create("ManualAdvance", "Force manual transition?"), CheckboxField::create("RandomStart", "Random Start?"))))));
$fields->extend("updateCMSFields", $fields);
return $fields;
}
示例12: getCMSFields
public function getCMSFields($params = null)
{
//fields that shouldn't be changed once coupon is used
$fields = new FieldList(array($tabset = new TabSet("Root", $maintab = new Tab("Main", TextField::create("Title"), CheckboxField::create("Active", "Active")->setDescription("Enable/disable all use of this discount."), HeaderField::create("ActionTitle", "Action", 3), $typefield = SelectionGroup::create("Type", array(new SelectionGroup_Item("Percent", $percentgroup = FieldGroup::create($percentfield = NumericField::create("Percent", "Percentage", "0.00")->setDescription("e.g. 0.05 = 5%, 0.5 = 50%, and 5 = 500%"), $maxamountfield = CurrencyField::create("MaxAmount", _t("MaxAmount", "Maximum Amount"))->setDescription("The total allowable discount. 0 means unlimited.")), "Discount by percentage"), new SelectionGroup_Item("Amount", $amountfield = CurrencyField::create("Amount", "Amount", "\$0.00"), "Discount by fixed amount")))->setTitle("Type"), OptionSetField::create("For", "Applies to", array("Order" => "Entire Order", "Cart" => "Cart Subtotal", "Shipping" => "Shipping Subtotal", "Items" => "Each Individual Item")), new Tab("Main", HeaderField::create("ConstraintsTitle", "Constraints", 3), LabelField::create("ConstraintsDescription", "Configure the requirements an order must meet for this discount to be valid:")), new TabSet("Constraints")))));
if (!$this->isInDB()) {
$fields->addFieldToTab("Root.Main", LiteralField::create("SaveNote", "<p class=\"message good\">More constraints will show up after you save for the first time.</p>"), "Constraints");
}
$this->extend("updateCMSFields", $fields, $params);
if ($count = $this->getUseCount()) {
$fields->addFieldsToTab("Root.Usage", array(HeaderField::create("UseCount", sprintf("This discount has been used {$count} time%s.", $count > 1 ? "s" : "")), HeaderField::create("TotalSavings", sprintf("A total of %s has been saved by customers using this discount.", $this->SavingsTotal), "3"), GridField::create("Orders", "Orders", $this->getAppliedOrders(), GridFieldConfig_RecordViewer::create()->removeComponentsByType("GridFieldViewButton"))));
}
if ($params && isset($params['forcetype'])) {
$valuefield = $params['forcetype'] == "Percent" ? $percentfield : $amountfield;
$fields->insertAfter($valuefield, "Type");
$fields->removeByName("Type");
} elseif ($this->Type && (double) $this->{$this->Type}) {
$valuefield = $this->Type == "Percent" ? $percentfield : $amountfield;
$fields->removeByName("Type");
$fields->insertAfter($valuefield, "ActionTitle");
$fields->replaceField($this->Type, $valuefield->performReadonlyTransformation());
if ($this->Type == "Percent") {
$fields->insertAfter($maxamountfield, "Percent");
}
}
return $fields;
}
示例13: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$gridConfig = singleton('Block')->has_extension('Sortable') ? GridFieldConfig_BlockEditor::create('SortOrder') : GridFieldConfig_BlockEditor::create();
$gridField = GridField::create('Blocks', _t('PageBlocks.BLOCK', 'Block', 'GridField Title'), $this->owner->Blocks(), $gridConfig);
$gridField->setModelClass('Block');
$fields->addFieldsToTab('Root.Main', array($gridField), 'Metadata');
}
示例14: getEditForm
public function getEditForm($id = null, $fields = null)
{
$classname = $this->modelClass;
$list = $classname::get();
$listField = GridField::create($this->sanitiseClassName($this->modelClass), false, $list, $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length'))->removeComponentsByType('GridFieldFilterHeader'));
if (!$this->stat('enable_sorting')) {
$summary_fields = Config::inst()->get($this->modelClass, 'summary_fields');
$sorting = array();
foreach ($summary_fields as $col) {
$sorting[$col] = 'FieldNameNoSorting';
}
$fieldConfig->getComponentByType('GridFieldSortableHeader')->setFieldSorting($sorting);
}
// Validation
if (singleton($this->modelClass)->hasMethod('getCMSValidator')) {
$detailValidator = singleton($this->modelClass)->getCMSValidator();
$listField->getConfig()->getComponentByType('GridFieldDetailForm')->setValidator($detailValidator);
}
$form = new Form($this, 'EditForm', new FieldList($listField), new FieldList());
$form->addExtraClass('cms-edit-form cms-panel-padded center');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm');
$form->setFormAction($editFormAction);
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
return $form;
}
示例15: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$sortable = singleton('CleanTeaser')->hasExtension('SortableDataExtension');
$config = GridFieldConfig_RelationEditor::create();
$config->addComponent($gridFieldForm = new GridFieldDetailForm());
$dataFields = array();
if (singleton('CleanTeaser')->hasExtension('CMSPublishableDataExtension')) {
$dataFields['PublishIndicator'] = 'Published';
}
$dataFields = array_merge($dataFields, array('Thumbnail' => 'Thumbnail', 'Title' => 'Title', 'CleanDescription' => 'Description'));
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields($dataFields);
$gridFieldForm->setTemplate('CMSGridFieldPopupForms');
if ($sortable) {
$config->addComponent(new GridFieldSortableRows('SortOrder'));
}
if (ClassInfo::exists('GridFieldBulkUpload')) {
$iu = new GridFieldBulkUpload('ImageID');
if (singleton('CleanTeaser')->hasExtension('ControlledFolderDataExtension')) {
$iu->setUfConfig('folderName', singleton('CleanTeaser')->getUploadFolder());
} else {
$iu->setUfConfig('folderName', CleanTeaser::$upload_folder);
}
$config->addComponent($iu);
}
if ($sortable) {
$data = $this->owner->CleanTeasers("ClassName = 'CleanTeaser'")->sort('SortOrder');
} else {
$data = $this->owner->CleanTeasers("ClassName = 'CleanTeaser'");
}
// $config->removeComponentsByType('GridFieldAddNewButton');
// if (ClassInfo::exists('GridFieldBulkUpload')) {
// $config->addComponent(new GridFieldAddNewMultiClass());
// }
$fields->addFieldToTab("Root.Teasers", GridField::create('CleanTeasers', 'CleanTeaser', $data, $config));
}