本文整理汇总了PHP中GridFieldConfig_RelationEditor::getComponentByType方法的典型用法代码示例。如果您正苦于以下问题:PHP GridFieldConfig_RelationEditor::getComponentByType方法的具体用法?PHP GridFieldConfig_RelationEditor::getComponentByType怎么用?PHP GridFieldConfig_RelationEditor::getComponentByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridFieldConfig_RelationEditor
的用法示例。
在下文中一共展示了GridFieldConfig_RelationEditor::getComponentByType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
public function getCMSFields()
{
$fields = FieldList::create(TabSet::create('Root'))->text('Title')->text('Code', 'Code', '', 5)->textarea('Description')->numeric('SessionCount', 'Number of sessions')->numeric('AlternateCount', 'Number of alternates')->checkbox('VotingVisible', "This category is visible to voters")->checkbox('ChairVisible', "This category is visible to track chairs")->hidden('SummitID', 'SummitID');
if ($this->ID > 0) {
//tags
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType(new GridFieldDataColumns());
$config->removeComponentsByType(new GridFieldDetailForm());
$completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
$completer->setResultsFormat('$Tag');
$completer->setSearchFields(array('Tag'));
$completer->setSearchList(Tag::get());
$editconf = new GridFieldDetailForm();
$editconf->setFields(FieldList::create(TextField::create('Tag', 'Tag'), DropdownField::create('ManyMany[Group]', 'Group', array('topics' => 'Topics', 'speaker' => 'Speaker', 'openstack projects mentioned' => 'OpenStack Projects Mentioned'))));
$summaryfieldsconf = new GridFieldDataColumns();
$summaryfieldsconf->setDisplayFields(array('Tag' => 'Tag', 'Group' => 'Group'));
$config->addComponent($editconf);
$config->addComponent($summaryfieldsconf, new GridFieldFilterHeader());
$tags = new GridField('AllowedTags', 'Tags', $this->AllowedTags(), $config);
$fields->addFieldToTab('Root.Main', $tags);
// extra questions for call-for-presentations
$config = new GridFieldConfig_RelationEditor();
$config->removeComponentsByType('GridFieldAddNewButton');
$multi_class_selector = new GridFieldAddNewMultiClass();
$multi_class_selector->setClasses(array('TrackTextBoxQuestionTemplate' => 'TextBox', 'TrackCheckBoxQuestionTemplate' => 'CheckBox', 'TrackCheckBoxListQuestionTemplate' => 'CheckBoxList', 'TrackRadioButtonListQuestionTemplate' => 'RadioButtonList', 'TrackDropDownQuestionTemplate' => 'ComboBox', 'TrackLiteralContentQuestionTemplate' => 'Literal'));
$config->addComponent($multi_class_selector);
$questions = new GridField('ExtraQuestions', 'Track Specific Questions', $this->ExtraQuestions(), $config);
$fields->addFieldToTab('Root.Main', $questions);
}
return $fields;
}
示例2: updateCMSFields
/**
* @param FieldList $fields
* @return FieldList|void
*/
public function updateCMSFields(FieldList $fields)
{
$oldFields = $fields->toArray();
foreach ($oldFields as $field) {
$fields->remove($field);
}
$fields->push(new TextField("Title", "Title"));
$fields->push(new HtmlEditorField("Summary", "Summary"));
$fields->push(new HtmlEditorField("Description", "Description"));
$fields->push(new MemberAutoCompleteField("Curator", "Curator"));
$fields->push($ddl = new DropdownField('ReleaseID', 'Release', OpenStackRelease::get()->map("ID", "Name")));
$ddl->setEmptyString('-- Select a Release --');
if ($this->owner->ID > 0) {
$components_config = new GridFieldConfig_RelationEditor(100);
$components = new GridField("OpenStackComponents", "Supported Release Components", $this->owner->OpenStackComponents(), $components_config);
$components_config->getComponentByType('GridFieldAddExistingAutocompleter')->setSearchList($this->getAllowedComponents());
$components_config->removeComponentsByType('GridFieldAddNewButton');
//$components_config->addComponent(new GridFieldSortableRows('OpenStackSampleConfig_OpenStackComponents.Order'));
$fields->push($components);
$fields->push($ddl = new DropdownField('TypeID', 'Type', OpenStackSampleConfigurationType::get()->filter('ReleaseID', $this->owner->ReleaseID)->map("ID", "Type")));
$ddl->setEmptyString('-- Select a Configuration Type --');
$related_notes_config = new GridFieldConfig_RecordEditor(100);
$related_notes = new GridField("RelatedNotes", "Related Notes", $this->owner->RelatedNotes(), $related_notes_config);
$related_notes_config->addComponent(new GridFieldSortableRows('Order'));
$fields->push($related_notes);
}
return $fields;
}
示例3: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$oldFields = $fields->toArray();
foreach ($oldFields as $field) {
$fields->remove($field);
}
$fields->push(new TextField("Type", "Type"));
$fields->push(new CheckboxField("IsDefault", "Is Default?"));
if ($this->owner->ID > 0) {
$config = new GridFieldConfig_RelationEditor(100);
$configurations = new GridField("SampleConfigurations", "Sample Configurations", $this->owner->SampleConfigurations(), $config);
$detailFormFields = new FieldList();
$detailFormFields->push(new CheckBoxField('IsDefault', 'Is Default?'));
$config->getComponentByType('GridFieldDetailForm')->setFields($detailFormFields);
$fields->push($configurations);
}
return $fields;
}
示例4: getCMSFields
public function getCMSFields()
{
$summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
$f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
$f->addFieldToTab('Root.Main', new TextField('Name', 'Name'));
$f->addFieldToTab('Root.Main', new ColorField('Color', 'Color'));
if ($this->ID > 0) {
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldEditButton');
$config->removeComponentsByType('GridFieldAddNewButton');
$config->addComponent(new GridFieldDeleteAction('unlinkrelation'));
$completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
$completer->setSearchList(PresentationCategory::get()->filter('SummitID', $summit_id));
$categories = new GridField('Categories', 'Presentation Category', $this->Categories(), $config);
$f->addFieldToTab('Root.Main', $categories);
}
$f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
return $f;
}
示例5: getCMSFields
public function getCMSFields()
{
$summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
$f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
$f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Short Description'));
$f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
$f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
$f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
$date->getDateField()->setConfig('showcalendar', true);
$date->setConfig('dateformat', 'dd/MM/yyyy');
$f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
$date->getDateField()->setConfig('showcalendar', true);
$date->setConfig('dateformat', 'dd/MM/yyyy');
$locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
$locations_source = array();
foreach ($locations as $l) {
$locations_source[$l->ID] = $l->getFullName();
}
$f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
$ddl_location->setEmptyString('-- Select a Location --');
$f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
$ddl_location->setEmptyString('-- Select a Event Type --');
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
if ($this->ID > 0) {
// summits types
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldEditButton');
$config->removeComponentsByType('GridFieldAddNewButton');
$completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
$completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
$summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
$f->addFieldToTab('Root.Main', $summit_types);
// sponsors
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldEditButton');
$config->removeComponentsByType('GridFieldAddNewButton');
$sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
$f->addFieldToTab('Root.Sponsors', $sponsors);
// feedback
$config = new GridFieldConfig_RecordEditor(100);
$config->removeComponentsByType('GridFieldAddNewButton');
$feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
$f->addFieldToTab('Root.Feedback', $feedback);
}
return $f;
}
示例6: getCMSFields
/**
* Caution: Only call on instances, not through a singleton.
* The "root group" fields will be created through {@link SecurityAdmin->EditForm()}.
*
* @return FieldList
*/
public function getCMSFields()
{
Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
$fields = new FieldList(new TabSet("Root", new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $parentidfield = DropdownField::create('ParentID', $this->fieldLabel('Parent'), Group::get()->exclude('ID', $this->ID)->map('ID', 'Breadcrumbs'))->setEmptyString(' '), new TextareaField('Description', $this->fieldLabel('Description'))), $permissionsTab = new Tab('Permissions', _t('SecurityAdmin.PERMISSIONS', 'Permissions'), $permissionsField = new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this))));
$parentidfield->setDescription(_t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles'));
// Filter permissions
// TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm
$permissionsField->setHiddenPermissions((array) Config::inst()->get('SecurityAdmin', 'hidden_permissions'));
if ($this->ID) {
$group = $this;
$config = new GridFieldConfig_RelationEditor();
$config->addComponent(new GridFieldButtonRow('after'));
$config->addComponents(new GridFieldExportButton('buttons-after-left'));
$config->addComponents(new GridFieldPrintButton('buttons-after-left'));
$config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$Title ($Email)')->setSearchFields(array('FirstName', 'Surname', 'Email'));
$config->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator())->setItemEditFormCallback(function ($form, $component) use($group) {
$record = $form->getRecord();
$groupsField = $form->Fields()->dataFieldByName('DirectGroups');
if ($groupsField) {
// If new records are created in a group context,
// set this group by default.
if ($record && !$record->ID) {
$groupsField->setValue($group->ID);
} elseif ($record && $record->ID) {
// TODO Mark disabled once chosen.js supports it
// $groupsField->setDisabledItems(array($group->ID));
$form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
}
}
});
$memberList = GridField::create('Members', false, $this->DirectMembers(), $config)->addExtraClass('members_grid');
// @todo Implement permission checking on GridField
//$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
$fields->addFieldToTab('Root.Members', $memberList);
}
// Only add a dropdown for HTML editor configurations if more than one is available.
// Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
$editorConfigMap = HtmlEditorConfig::get_available_configs_map();
if (count($editorConfigMap) > 1) {
$fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
}
if (!Permission::check('EDIT_PERMISSIONS')) {
$fields->removeFieldFromTab('Root', 'Permissions');
}
// Only show the "Roles" tab if permissions are granted to edit them,
// and at least one role exists
if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
$fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
$fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "Roles are predefined sets of permissions, and can be assigned to groups.<br />" . "They are inherited from parent groups if required.") . '<br />' . sprintf('<a href="%s" class="add-role">%s</a>', singleton('SecurityAdmin')->Link('show/root#Root_Roles'), _t('Group.RolesAddEditLink', 'Manage roles')) . "</p>"));
// Add roles (and disable all checkboxes for inherited roles)
$allRoles = PermissionRole::get();
if (Permission::check('ADMIN')) {
$allRoles = $allRoles->filter("OnlyAdminCanApply", 0);
}
if ($this->ID) {
$groupRoles = $this->Roles();
$inheritedRoles = new ArrayList();
$ancestors = $this->getAncestors();
foreach ($ancestors as $ancestor) {
$ancestorRoles = $ancestor->Roles();
if ($ancestorRoles) {
$inheritedRoles->merge($ancestorRoles);
}
}
$groupRoleIDs = $groupRoles->column('ID') + $inheritedRoles->column('ID');
$inheritedRoleIDs = $inheritedRoles->column('ID');
} else {
$groupRoleIDs = array();
$inheritedRoleIDs = array();
}
$rolesField = ListboxField::create('Roles', false, $allRoles->map()->toArray())->setMultiple(true)->setDefaultItems($groupRoleIDs)->setAttribute('data-placeholder', _t('Group.AddRole', 'Add a role for this group'))->setDisabledItems($inheritedRoleIDs);
if (!$allRoles->Count()) {
$rolesField->setAttribute('data-placeholder', _t('Group.NoRoles', 'No roles found'));
}
$fields->addFieldToTab('Root.Roles', $rolesField);
}
$fields->push($idField = new HiddenField("ID"));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例7: getCMSFields
public function getCMSFields()
{
Requirements::customScript("\n jQuery( document ).ready(function() {\n jQuery('body').on('change','#Form_ItemEditForm_RSVPTemplateID',\n function(){\n jQuery('#Form_ItemEditForm_action_save').click();\n }\n );\n });");
$summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
$f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
$f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
$f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Abstract'));
$f->addFieldToTab('Root.Main', new TextField('HeadCount', 'HeadCount'));
$f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
$f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
$f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
$date->getDateField()->setConfig('showcalendar', true);
$date->setConfig('dateformat', 'dd/MM/yyyy');
$f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
$date->getDateField()->setConfig('showcalendar', true);
$date->setConfig('dateformat', 'dd/MM/yyyy');
$f->addFieldsToTab('Root.Main', new ReadonlyField('AvgFeedbackRate', 'AvgFeedbackRate'));
$locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
$locations_source = array();
foreach ($locations as $l) {
$locations_source[$l->ID] = $l->getFullName();
}
$f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
$ddl_location->setEmptyString('-- Select a Location --');
$f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
$ddl_location->setEmptyString('-- Select a Event Type --');
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
if ($this->ID > 0) {
// summits types
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldEditButton');
$config->removeComponentsByType('GridFieldAddNewButton');
$completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
$completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
$summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
$f->addFieldToTab('Root.Main', $summit_types);
// sponsors
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldEditButton');
$config->removeComponentsByType('GridFieldAddNewButton');
$sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
$f->addFieldToTab('Root.Sponsors', $sponsors);
// feedback
$config = new GridFieldConfig_RecordEditor(100);
$config->removeComponentsByType('GridFieldAddNewButton');
$config->addComponent(new GridFieldAjaxRefresh(1000, false));
$feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
$f->addFieldToTab('Root.Feedback', $feedback);
// rsvp
$f->addFieldsToTab('Root.RSVP', new TextField('RSVPLink', 'RSVP External Link'));
$rsvp_template = new DropdownField('RSVPTemplateID', 'Select a Template', RSVPTemplate::get()->filter('SummitID', $summit_id)->map());
$rsvp_template->setEmptyString('-- View All Templates --');
$f->addFieldToTab('Root.RSVP', LiteralField::create('AddNew', 'Or add a new custom RSVP Configuration'));
$f->addFieldToTab('Root.RSVP', $rsvp_template);
$f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserNumber', 'Max # Number'));
$f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserWaitListNumber', 'Max # Wait List'));
$f->addFieldToTab('Root.RSVP', $rsvp_template);
if ($this->RSVPTemplate()->exists()) {
$config = new GridFieldConfig_RecordEditor(100);
$config->removeComponentsByType('GridFieldAddNewButton');
$config->addComponent(new GridFieldAjaxRefresh(1000, false));
$rsvps = new GridField('RSVPSubmissions', 'RSVP Submissions', $this->RSVPSubmissions(), $config);
$f->addFieldToTab('Root.RSVP', $rsvps);
}
}
if ($this->ID > 0) {
$_REQUEST['SummitEventID'] = $this->ID;
}
return $f;
}
示例8: getCMSFields
/**
* @return FieldList
*/
public function getCMSFields()
{
$summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
$f = parent::getCMSFields();
$f->removeByName('TypeID');
$f->dropdown('Level', 'Level', $this->dbObject('Level')->enumValues())->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->listbox('Topics', 'Topics', PresentationTopic::get()->map('ID', 'Title')->toArray())->configure()->setMultiple(true)->end()->text('OtherTopic', 'Other topic')->htmleditor('ProblemAddressed', 'What is the problem or use case you’re addressing in this session?')->htmleditor('AttendeesExpectedLearnt', 'What should attendees expect to learn?')->tab('Preview')->literal('preview', sprintf('<iframe width="%s" height="%s" frameborder="0" src="%s"></iframe>', '100%', '400', Director::absoluteBaseURL() . $this->PreviewLink()));
$f->addFieldToTab('Root.Main', $ddl_type = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter(array('SummitID' => $summit_id))->where(" Type ='Presentation' OR Type ='Keynotes' OR Type ='Panel' ")->map('ID', 'Type')));
$ddl_type->setEmptyString('-- Select a Presentation Type --');
if ($this->ID > 0) {
// speakers
$config = new GridFieldConfig_RelationEditor(100);
$config->removeComponentsByType('GridFieldAddNewButton');
$speakers = new GridField('Speakers', 'Speakers', $this->Speakers(), $config);
$f->addFieldToTab('Root.Speakers', $speakers);
$config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$Name - $Member.Email')->setSearchList($this->getAllowedSpeakers());
// moderator
$f->addFieldToTab('Root.Speakers', $ddl_moderator = new DropdownField('ModeratorID', 'Moderator', $this->Speakers()->map('ID', 'Name')));
$ddl_moderator->setEmptyString('-- Select a Moderator --');
$config = GridFieldConfig_RecordEditor::create(100);
$config->removeComponentsByType('GridFieldAddNewButton');
$multi_class_selector = new GridFieldAddNewMultiClass();
$multi_class_selector->setClasses(array('PresentationVideo' => 'Video', 'PresentationSlide' => 'Slide', 'PresentationLink' => 'Link'));
$config->addComponent($multi_class_selector);
$config->addComponent($sort = new GridFieldSortableRows('Order'));
$gridField = new GridField('Materials', 'Materials', $this->Materials(), $config);
$f->addFieldToTab('Root.Materials', $gridField);
}
return $f;
}