本文整理汇总了PHP中TabSet::setTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP TabSet::setTemplate方法的具体用法?PHP TabSet::setTemplate怎么用?PHP TabSet::setTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabSet
的用法示例。
在下文中一共展示了TabSet::setTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEditForm
/**
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
$newComments = Comment::get()->filter('Moderated', 0);
$newGrid = new CommentsGridField('NewComments', _t('CommentsAdmin.NewComments', 'New'), $newComments, CommentsGridFieldConfig::create());
$approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0);
$approvedGrid = new CommentsGridField('ApprovedComments', _t('CommentsAdmin.ApprovedComments', 'Approved'), $approvedComments, CommentsGridFieldConfig::create());
$spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1);
$spamGrid = new CommentsGridField('SpamComments', _t('CommentsAdmin.SpamComments', 'Spam'), $spamComments, CommentsGridFieldConfig::create());
$newCount = '(' . count($newComments) . ')';
$approvedCount = '(' . count($approvedComments) . ')';
$spamCount = '(' . count($spamComments) . ')';
$fields = new FieldList($root = new TabSet('Root', new Tab('NewComments', _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, $newGrid), new Tab('ApprovedComments', _t('CommentAdmin.ApprovedComments', 'Approved') . ' ' . $approvedCount, $approvedGrid), new Tab('SpamComments', _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, $spamGrid)));
$root->setTemplate('CMSTabSet');
$actions = new FieldList();
$form = new Form($this, 'EditForm', $fields, $actions);
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
}
$this->extend('updateEditForm', $form);
return $form;
}
示例2: getEditForm
/**
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
$commentsConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldSortableHeader(), new GridFieldPaginator(25), new GridFieldDeleteAction(), new GridFieldDetailForm(), new GridFieldExportButton(), new GridFieldEditButton(), new GridFieldDetailForm());
$needs = new GridField('Comments', _t('CommentsAdmin.NeedsModeration', 'Needs Moderation'), Comment::get()->where('Moderated = 0'), $commentsConfig);
$moderated = new GridField('CommentsModerated', _t('CommentsAdmin.CommentsModerated'), Comment::get()->where('Moderated = 1'), $commentsConfig);
$fields = new FieldList($root = new TabSet('Root', new Tab('NeedsModeration', _t('CommentAdmin.NeedsModeration', 'Needs Moderation'), $needs), new Tab('Comments', _t('CommentAdmin.Moderated', 'Moderated'), $moderated)));
$root->setTemplate('CMSTabSet');
$actions = new FieldList();
$form = new Form($this, 'EditForm', $fields, $actions);
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
}
$this->extend('updateEditForm', $form);
return $form;
}
示例3: 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;
}
示例4: Form
/**
* This method should be overloaded to build out the detail form.
*
* @return Form
*/
public function Form()
{
$form = new Form($this, 'Form', new FieldList($root = new TabSet('Root', new Tab('Main'))), new FieldList());
if ($this->getTopLevelController() instanceof LeftAndMain) {
$form->setTemplate('LeftAndMain_EditForm');
$form->addExtraClass('cms-content cms-edit-form cms-tabset center');
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
$root->setTemplate('CMSTabSet');
$form->Backlink = $this->getBackLink();
}
return $form;
}
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-gridfieldextensions,代码行数:17,代码来源:GridFieldRequestHandler.php
示例5: 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 GridFieldExportButton()))->addExtraClass("members_grid");
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
$columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
$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'))), new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" border="0"></iframe>', $this->Link('memberimport')))), $groupsTab = new Tab('Groups', singleton('Group')->plural_name(), $groupList, new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" border="0"></iframe>', $this->Link('groupimport'))))), new HiddenField('ID', false, 0));
$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->request->param('Action');
if ($actionParam == 'groups') {
$groupsTab->addExtraClass('ui-state-selected');
} elseif ($actionParam == 'users') {
$usersTab->addExtraClass('ui-state-selected');
} elseif ($actionParam == 'roles') {
$rolesTab->addExtraClass('ui-state-selected');
}
$actions = new FieldList();
$form = new Form($this, 'EditForm', $fields, $actions);
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
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;
}
示例6: getEditForm
/**
* The content of the main section of the page
* List current form fields and allow user to modify their data
*
* @see LeftAndMain::getEditForm()
*/
public function getEditForm($id = null, $fields = null)
{
// Save button
$actions = new FieldList(FormAction::create('save', _t('CMSMain.SAVE', 'Save'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
// Form tabs
$fieldsTab = new Tab('Fields', _t('EditableFieldAdmin.Fields', 'Fields'));
$groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name());
// Form tab container
$tabSet = new TabSet('Root', $fieldsTab, $groupsTab);
$tabSet->setTemplate('CMSTabSet');
// Activate tab based on request param
$actionParam = $this->request->param('Action');
if ($actionParam == 'fields') {
$fieldsTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'groups') {
$groupsTab->addExtraClass('ui-state-active');
}
// Form field list
$fields = new FieldList([$tabSet]);
// Add field to first tab
$fields->addFieldToTab('Root.Fields', new EditableFieldEditor("Fields", 'Fields', ""));
// Add field to second tab
$groupsConfig = GridFieldConfig_RecordEditor::create();
$groupsField = GridField::create('EditableFieldGroup', singleton('Group')->i18n_plural_name(), EditableFieldGroup::get(), $groupsConfig);
$component = $groupsConfig->getComponentByType('GridFieldAddNewButton');
$component->setButtonName(_t('EditableFieldAdmin.AddGroup', 'Add Group'));
$fields->addFieldToTab('Root.Groups', $groupsField);
// The edit form
$form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->loadDataFrom($this);
// Render correct responses on validation errors
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->disableDefaultAction();
// Form layout
$form->addExtraClass('cms-content cms-edit-form center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
// Allow decorators to modify the form
$this->extend('updateEditForm', $form);
return $form;
}
示例7: getEditForm
/**
* Returns a GridField of messages
* @return CMSForm
*/
public function getEditForm($id = null, $fields = null)
{
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
// Build gridfield
$messageListConfig = GridFieldConfig::create()->addComponents(new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldFooter());
$messages = $this->Messages();
if (is_string($messages)) {
// The api returned an error
$messagesList = new LiteralField("MessageAlert", '<div class="message bad">' . $messages . '</div>');
} else {
$messagesList = GridField::create('Messages', false, $messages, $messageListConfig)->addExtraClass("messages_grid");
$columns = $messageListConfig->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(['transmission_id' => _t('SparkPostAdmin.EventTransmissionId', 'Id'), 'timestamp' => _t('SparkPostAdmin.EventDate', 'Date'), 'type' => _t('SparkPostAdmin.EventType', 'Type'), 'rcpt_to' => _t('SparkPostAdmin.EventRecipient', 'Recipient'), 'subject' => _t('SparkPostAdmin.EventSubject', 'Subject'), 'friendly_from' => _t('SparkPostAdmin.EventSender', 'Sender')]);
$columns->setFieldFormatting(['timestamp' => function ($value, &$item) {
return date('Y-m-d H:i:s', strtotime($value));
}]);
// Validator setup
$validator = null;
if ($record && method_exists($record, 'getValidator')) {
$validator = $record->getValidator();
}
if ($validator) {
$messageListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
}
}
// Create tabs
$messagesTab = new Tab('Messages', _t('SparkPostAdmin.Messages', 'Messages'), $messagesList, new HiddenField('ID', false, 0));
$fields = new FieldList($root = new TabSet('Root', $messagesTab));
if ($this->CanConfigureApi()) {
$settingsTab = new Tab('Settings', _t('SparkPostAdmin.Settings', 'Settings'));
$webhookTabData = $this->WebhookTab();
$settingsTab->push($webhookTabData);
$domainTabData = $this->DomainTab();
$settingsTab->push($domainTabData);
$fields->addFieldToTab('Root', $settingsTab);
}
// Tab nav in CMS is rendered through separate template
$root->setTemplate('CMSTabSet');
// Manage tabs state
$actionParam = $this->getRequest()->param('Action');
if ($actionParam == 'setting') {
$settingsTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'messages') {
$messagesTab->addExtraClass('ui-state-active');
}
$actions = new FieldList();
// Create cms form
$form = CMSForm::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$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;
}