本文整理汇总了PHP中Form::addExtraClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addExtraClass方法的具体用法?PHP Form::addExtraClass怎么用?PHP Form::addExtraClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Form
的用法示例。
在下文中一共展示了Form::addExtraClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
*/
function getEditForm($id = null, $fields = null)
{
$siteConfig = SiteConfig::current_site_config();
$fields = $siteConfig->getCMSFields();
$actions = $siteConfig->getCMSActions();
$form = new Form($this, 'EditForm', $fields, $actions);
$form->addExtraClass('root-form');
$form->addExtraClass('cms-edit-form cms-panel-padded center');
// don't add data-pjax-fragment=CurrentForm, its added in the content template instead
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->setHTMLID('Form_EditForm');
$form->loadDataFrom($siteConfig);
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// Use <button> to allow full jQuery UI styling
$actions = $actions->dataFields();
if ($actions) {
foreach ($actions as $action) {
$action->setUseButtonTag(true);
}
}
$this->extend('updateEditForm', $form);
return $form;
}
示例3: 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;
}
示例4: injectNavigatorAndPreview
/**
* @param \Form $form
* @param \FieldList $fields
*/
private function injectNavigatorAndPreview(&$form, &$fields)
{
$template = Controller::curr()->getTemplatesWithSuffix('_SilverStripeNavigator');
$navigator = new SilverStripeNavigator($this->owner->record);
$field = new LiteralField('SilverStripeNavigator', $navigator->renderWith($template));
$field->setAllowHTML(true);
$fields->push($field);
$form->addExtraClass('cms-previewable');
$form->addExtraClass(' cms-previewabledataobject');
$form->removeExtraClass('cms-panel-padded center');
}
示例5: 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;
}
示例6: ConvertObjectForm
/**
* Form used for defining the conversion form
* @return {Form} Form to be used for configuring the conversion
*/
public function ConvertObjectForm()
{
//Reset the reading stage
Versioned::reset();
$fields = new FieldList(CompositeField::create($convertModeField = new OptionsetField('ConvertMode', '', array('ReplacePage' => _t('KapostAdmin.REPLACES_AN_EXISTING_PAGE', '_This replaces an existing page'), 'NewPage' => _t('KapostAdmin.IS_NEW_PAGE', '_This is a new page')), 'NewPage'))->addExtraClass('kapostConvertLeftSide'), CompositeField::create($replacePageField = TreeDropdownField::create('ReplacePageID', _t('KapostAdmin.REPLACE_PAGE', '_Replace this page'), 'SiteTree')->addExtraClass('replace-page-id'), TreeDropdownField::create('ParentPageID', _t('KapostAdmin.USE_AS_PARENT', '_Use this page as the parent for the new page, leave empty for a top level page'), 'SiteTree')->addExtraClass('parent-page-id'))->addExtraClass('kapostConvertRightSide'));
$actions = new FieldList(FormAction::create('doConvertObject', _t('KapostAdmin.CONTINUE_CONVERT', '_Continue'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'kapost-convert'));
$validator = new RequiredFields('ConvertMode');
$form = new Form($this, 'ConvertObjectForm', $fields, $actions, $validator);
$form->addExtraClass('KapostAdmin center')->setAttribute('data-layout-type', 'border')->setTemplate('KapostAdmin_ConvertForm');
//Handle pages to see if the page exists
$convertToClass = $this->getDestinationClass();
if ($convertToClass !== false && ($convertToClass == 'SiteTree' || is_subclass_of($convertToClass, 'SiteTree'))) {
$obj = SiteTree::get()->filter('KapostRefID', Convert::raw2sql($this->record->KapostRefID))->first();
if (!empty($obj) && $obj !== false && $obj->ID > 0) {
$convertModeField->setValue('ReplacePage');
$replacePageField->setValue($obj->ID);
$recordTitle = $this->record->Title;
if (!empty($recordTitle) && $recordTitle != $obj->Title) {
$urlFieldLabel = _t('KapostAdmin.TITLE_CHANGE_DETECT', '_The title differs from the page being replaced, it was "{wastitle}" and will be changed to "{newtitle}". Do you want to update the URL Segment?', array('wastitle' => $obj->Title, 'newtitle' => $recordTitle));
$fields->push(CheckboxField::create('UpdateURLSegment', $urlFieldLabel)->addExtraClass('urlsegmentcheck')->setAttribute('data-replace-id', $obj->ID)->setForm($form)->setDescription(_t('KapostAdmin.NEW_URL_SEGMENT', '_The new URL Segment will be or will be close to "{newsegment}"', array('newsegment' => $obj->generateURLSegment($recordTitle)))));
}
}
}
Requirements::css(KAPOST_DIR . '/css/KapostAdmin.css');
Requirements::add_i18n_javascript(KAPOST_DIR . '/javascript/lang/');
Requirements::javascript(KAPOST_DIR . '/javascript/KapostAdmin_convertPopup.js');
//Allow extensions to adjust the form
$this->extend('updateConvertObjectForm', $form, $this->record);
return $form;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge,代码行数:34,代码来源:KapostGridFieldDetailForm_ItemRequest.php
示例7: getEditForm
public function getEditForm($id = null, $fields = null)
{
$tabs = new TabSet('Root', new Tab('Main'));
$fields = new FieldList($tabs);
$caches = array();
$all_caches = SimpleCache::$cache_configs;
foreach ($all_caches as $name => $cacheInfo) {
$cache = $this->getCache($name);
if ($cache) {
$stats = $cache->stats();
$fields->addFieldToTab('Root.Main', new HeaderField($name . 'header', $name));
$fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Hits', 'Hits', $stats->hits));
$fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Miss', 'Miss', $stats->misses));
$fields->addFieldToTab('Root.Main', new ReadonlyField($name . 'Count', 'Count', $stats->count));
$caches[$name] = $name;
}
}
if (count($caches)) {
$fields->addFieldToTab('Root.Clear', new CheckboxSetField('ToClear', 'Caches to clear', $caches));
}
$actions = new FieldList(new FormAction('clear', 'Clear'));
$form = new Form($this, 'EditForm', $fields, $actions);
$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
return $form;
}
示例8: getEditForm
/**
* @return Form
* @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
*/
public function getEditForm($id = null, $fields = null)
{
Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
$folder = $this->currentPage();
$uploadField = UploadField::create('AssetUploadField', '');
$uploadField->setConfig('previewMaxWidth', 40);
$uploadField->setConfig('previewMaxHeight', 30);
$uploadField->addExtraClass('ss-assetuploadfield');
$uploadField->removeExtraClass('ss-uploadfield');
$uploadField->setTemplate('AssetUploadField');
if ($folder->exists() && $folder->getFilename()) {
// The Upload class expects a folder relative *within* assets/
$path = preg_replace('/^' . ASSETS_DIR . '\\//', '', $folder->getFilename());
$uploadField->setFolderName($path);
} else {
$uploadField->setFolderName(ASSETS_DIR);
}
$exts = $uploadField->getValidator()->getAllowedExtensions();
asort($exts);
$form = new Form($this, 'getEditForm', new FieldList($uploadField, new LiteralField('AllowedExtensions', sprintf('<p>%s: %s</p>', _t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'), implode('<em>, </em>', $exts))), new HiddenField('ID')), new FieldList());
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
// Don't use AssetAdmin_EditForm, as it assumes a different panel structure
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$form->Fields()->push(new LiteralField('BackLink', sprintf('<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>', Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0), _t('AssetAdmin.BackToFolder', 'Back to folder'))));
$form->loadDataFrom($folder);
return $form;
}
示例9: SearchForm
/**
* @return Form
*/
public function SearchForm()
{
$form = new Form($this, 'SearchForm', $this->context->getFields(), new FieldList(FormAction::create('doSearch', _t('GridFieldExtensions.SEARCH', 'Search'))->setUseButtonTag(true)->addExtraClass('ss-ui-button')->setAttribute('data-icon', 'magnifier')));
$form->addExtraClass('stacked add-existing-search-form');
$form->setFormMethod('GET');
return $form;
}
开发者ID:helpfulrobot,项目名称:ajshort-silverstripe-gridfieldextensions,代码行数:10,代码来源:GridFieldAddExistingSearchHandler.php
示例10: getEditForm
/**
* Returns the edit form for this admin.
*
* @param type $id
* @param type $fields
*
* @return Form
*/
public function getEditForm($id = null, $fields = null)
{
$fields = new FieldList();
$desc = _t('SilvercartProductImageAdmin.Description');
$descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc));
$uploadField = new UploadField('SilvercartProductImages', _t('SilvercartProductImageAdmin.UploadProductImages', 'Upload product images'));
$uploadField->setFolderName(SilvercartProductImageImporter::get_relative_upload_folder());
$fields->push($uploadField);
$fields->push($descriptionField);
if (!SilvercartProductImageImporter::is_installed()) {
$cronTitle = _t('SilvercartProductImageAdmin.CronNotInstalledTitle') . ':';
$cron = _t('SilvercartProductImageAdmin.CronNotInstalledDescription');
$cronjobInfoField = new SilvercartAlertDangerField('SilvercartProductImagesCronjobInfo', str_replace(PHP_EOL, '<br/>', $cron), $cronTitle);
$fields->insertAfter('SilvercartProductImages', $cronjobInfoField);
} elseif (SilvercartProductImageImporter::is_running()) {
$cronTitle = _t('SilvercartProductImageAdmin.CronIsRunningTitle') . ':';
$cron = _t('SilvercartProductImageAdmin.CronIsRunningDescription');
$cronjobInfoField = new SilvercartAlertSuccessField('SilvercartProductImagesCronjobInfo', str_replace(PHP_EOL, '<br/>', $cron), $cronTitle);
$fields->insertAfter('SilvercartProductImages', $cronjobInfoField);
}
$uploadedFiles = $this->getUploadedFiles();
if (count($uploadedFiles) > 0) {
$uploadedFilesInfo = '<br/>' . implode('<br/>', $uploadedFiles);
$fileInfoField = new SilvercartAlertWarningField('SilvercartProductImagesFileInfo', $uploadedFilesInfo, _t('SilvercartProductImageAdmin.FileInfoTitle'));
$fields->insertAfter('SilvercartProductImages', $fileInfoField);
}
$actions = new FieldList();
$form = new Form($this, "EditForm", $fields, $actions);
$form->addExtraClass('cms-edit-form cms-panel-padded center ' . $this->BaseCSSClasses());
$form->loadDataFrom($this->request->getVars());
$this->extend('updateEditForm', $form);
return $form;
}
示例11: AddForm
/**
* @return Form
*/
public function AddForm()
{
$fields = new FieldList(new LiteralField('SelectFieldType', '<p><strong>Please select a field type to add:</strong></p>'), $df = new DropdownField('ClassName', '', $this->getFieldTypes(), null, null));
$df->setHasEmptyDefault(true);
if ($schemaID = (int) $this->request->param('ID')) {
$fields->push(new HiddenField('SchemaID', '', $schemaID));
}
$actions = new FieldList(FormAction::create('doAddField', 'Create')->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
// Add a Cancel link which is a button-like link and link back to one level up.
$curmbs = $this->Breadcrumbs();
if ($curmbs && $curmbs->count() >= 2) {
$one_level_up = $curmbs->offsetGet($curmbs->count() - 2);
$text = "\n\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\n\t\t\t\tCancel\n\t\t\t</a>";
$actions->push(new LiteralField('cancelbutton', $text));
}
$form = new Form($this, 'AddForm', $fields, $actions);
$toplevelController = $this->getToplevelController();
$form->setTemplate('LeftAndMain_EditForm');
$form->addExtraClass('cms-content cms-edit-form center ss-tabset stacked');
$form->setAttribute('data-pjax-fragment', 'CurrentForm Content');
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
//var_dump($this->popupController); die;
$parents = $this->popupController->Breadcrumbs(false)->items;
$form->Backlink = array_pop($parents)->Link;
return $form;
}
示例12: AddForm
/**
* @return Form
*/
public function AddForm()
{
$record = $this->currentPage();
$moduleTypes = array();
foreach ($this->ModuleTypes() as $type) {
$html = sprintf('<span class="page-icon class-%s"></span><strong class="title">%s</strong><span class="description">%s</span>', $type->getField('Title'), $type->getField('AddAction'), $type->getField('Description'));
$moduleTypes[$type->getField('ClassName')] = $html;
}
// Ensure generic page type shows on top
if (isset($moduleTypes['Page'])) {
$pageTitle = $moduleTypes['Page'];
$moduleTypes = array_merge(array('Page' => $pageTitle), $moduleTypes);
}
$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><span class="title">%s</span></span>';
$topTitle = _t('CMSPageAddController.ParentMode_top', 'Top level');
$childTitle = _t('CMSPageAddController.ParentMode_child', 'Under another page');
$fields = new FieldList($typeField = new OptionsetField("ModuleType", sprintf($numericLabelTmpl, 1, _t('ContentModuleMain.ChooseModuleType', 'Choose module type')), $moduleTypes));
$actions = new FieldList(FormAction::create("doAdd", _t('CMSMain.Create', "Create"))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
$this->extend('updateModuleOptions', $fields);
$form = new Form($this, "AddForm", $fields, $actions);
$form->addExtraClass('cms-add-form stacked cms-content center cms-edit-form ' . $this->BaseCSSClasses());
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
if ($parentID = $this->request->getVar('ParentID')) {
$form->Fields()->dataFieldByName('ParentID')->setValue((int) $parentID);
}
return $form;
}
示例13: LogsForm
/**
* Form used for displaying the currently logged items
*/
public function LogsForm()
{
$fields = new FieldList(DropdownField::create('CalledMethod', _t('KapostBridgeLogViewer.CALLED_METHOD', '_Called Method'), array('blogger.getUsersBlogs' => 'blogger.getUsersBlogs', 'kapost.getPreview' => 'kapost.getPreview', 'metaWeblog.editPost' => 'metaWeblog.editPost', 'metaWeblog.getCategories' => 'metaWeblog.getCategories', 'metaWeblog.getPost' => 'metaWeblog.getPost', 'metaWeblog.newMediaObject' => 'metaWeblog.newMediaObject', 'metaWeblog.newPost' => 'metaWeblog.newPost', 'system.listMethods' => 'system.listMethods'))->setEmptyString('--- ' . _t('KapostBridgeLogViewer.FILTER_BY_METHOD', '_Filter by Method') . ' ---'), $startDate = new DatetimeField('LogStartDate', _t('KapostBridgeLogViewer.START_DATE_TIME', '_Start Date/Time')), $endDate = new DatetimeField('LogEndDate', _t('KapostBridgeLogViewer.END_DATE_TIME', '_End Date/Time')));
$startDate->getDateField()->setConfig('showcalendar', true);
$endDate->getDateField()->setConfig('showcalendar', true);
$actions = new FieldList(FormAction::create('doApplyFilters', _t('KapostBridgeLogViewer.APPLY_FILTER', '_Apply Filter'))->addExtraClass('ss-ui-action-constructive')->setUseButtonTag(true), Object::create('ResetFormAction', 'clear', _t('KapostBridgeLogViewer.RESET', '_Reset'))->setUseButtonTag(true));
$form = new Form($this, 'LogsForm', $fields, $actions);
$form->addExtraClass('log-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator();
// Load the form with previously sent search data
$getVars = $this->request->getVars();
//Workaround for start date field with no date or time
if (array_key_exists('LogStartDate', $getVars)) {
if (array_key_exists('date', $getVars['LogStartDate']) && !array_key_exists('time', $getVars['LogStartDate'])) {
$getVars['LogStartDate']['time'] = '00:00:00';
} else {
if (!array_key_exists('date', $getVars['LogStartDate']) && array_key_exists('time', $getVars['LogStartDate'])) {
unset($getVars['LogStartDate']);
//Remove if there is no date present
}
}
}
//Workaround for end date field with no date or time
if (array_key_exists('LogEndDate', $getVars)) {
if (array_key_exists('date', $getVars['LogEndDate']) && !array_key_exists('time', $getVars['LogEndDate'])) {
$getVars['LogEndDate']['time'] = '23:59:59';
} else {
if (!array_key_exists('date', $getVars['LogEndDate']) && array_key_exists('time', $getVars['LogEndDate'])) {
unset($getVars['LogEndDate']);
//Remove if there is no date present
}
}
}
$form->loadDataFrom($getVars);
return $form;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge-logger,代码行数:38,代码来源:KapostBridgeLogViewer.php
示例14: updateProfileForm
public function updateProfileForm(Form $form)
{
if (!Config::inst()->get('BootstrapForm', 'bootstrap_included')) {
Requirements::css(BOOTSTRAP_FORMS_DIR . '/css/bootstrap.css');
}
if (!Config::inst()->get('BootstrapForm', 'jquery_included')) {
Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
}
if (!Config::inst()->get('BootstrapForm', 'bootstrap_form_included')) {
Requirements::javascript(BOOTSTRAP_FORMS_DIR . "/javascript/bootstrap_forms.js");
}
$form->Fields()->bootstrapify();
$form->Actions()->bootstrapify();
$form->addExtraClass('well');
$form->addExtraClass('form-horizontal');
$form->setTemplate('BootstrapForm');
}
示例15: 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')->i18n_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;
}