/** * @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; }
/** * @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; }
/** * @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; }
/** * @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'); }
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; }
/** * 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; }
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; }
/** * @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; }
/** * @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; }
/** * 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; }
/** * @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; }
/** * @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; }
/** * 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; }
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'); }
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; }
public function alterCommentForm(Form $form) { $form->transform(new FoundationFormTransformation()); $form->setTemplate('FoundationCommentingControllerForm', 'FoundationForm', 'Form'); $form->addExtraClass('custom'); if ($form->hasExtension('FormSpamProtectionExtension')) { $form->enableSpamProtection(); } }
/** * Builds an item edit form. The arguments to getCMSFields() are the popupController and * popupFormName, however this is an experimental API and may change. * * @todo In the future, we will probably need to come up with a tigher object representing a partially * complete controller with gaps for extra functionality. This, for example, would be a better way * of letting Security/login put its log-in form inside a UI specified elsewhere. * * @return Form */ function ItemEditForm() { if (empty($this->record)) { $controller = Controller::curr(); $noActionURL = $controller->removeAction($_REQUEST['url']); $controller->getResponse()->removeHeader('Location'); //clear the existing redirect return $controller->redirect($noActionURL, 302); } $actions = new FieldList(); if ($this->record->ID !== 0) { $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Save', 'Save'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')); $actions->push(FormAction::create('doDelete', _t('GridFieldDetailForm.Delete', 'Delete'))->addExtraClass('ss-ui-action-destructive')); } else { // adding new record //Change the Save label to 'Create' $actions->push(FormAction::create('doSave', _t('GridFieldDetailForm.Create', 'Create'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'add')); // 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); $cancelText = _t('GridFieldDetailForm.CancelBtn', 'Cancel'); $text = "\r\n\t\t\t\t<a class=\"crumb ss-ui-button ss-ui-action-destructive cms-panel-link ui-corner-all\" href=\"" . $one_level_up->Link . "\">\r\n\t\t\t\t\t{$cancelText}\r\n\t\t\t\t</a>"; $actions->push(new LiteralField('cancelbutton', $text)); } } $fk = $this->gridField->getList()->foreignKey; $this->record->{$fk} = $this->gridField->getList()->foreignID; $form = new Form($this, 'ItemEditForm', $this->record->getCMSFields(), $actions, $this->component->getValidator()); $form->loadDataFrom($this->record); // TODO Coupling with CMS $toplevelController = $this->getToplevelController(); if ($toplevelController && $toplevelController instanceof LeftAndMain) { // Always show with base template (full width, no other panels), // regardless of overloaded CMS controller templates. // TODO Allow customization, e.g. to display an edit form alongside a search form from the CMS controller $form->setTemplate('LeftAndMain_EditForm'); $form->addExtraClass('cms-content cms-edit-form center ss-tabset'); $form->setAttribute('data-pjax-fragment', 'CurrentForm Content'); if ($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); } if ($toplevelController->hasMethod('Backlink')) { $form->Backlink = $toplevelController->Backlink(); } elseif ($this->popupController->hasMethod('Breadcrumbs')) { $parents = $this->popupController->Breadcrumbs(false)->items; $form->Backlink = array_pop($parents)->Link; } else { $form->Backlink = $toplevelController->Link(); } } $cb = $this->component->getItemEditFormCallback(); if ($cb) { $cb($form, $this); } return $form; }
function PopupForm() { $form = new Form($this, "{$this->name}/PopupForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', 'Edit Source'))), $codeField = new CodeEditorField('TinyMCESource', '')), new FieldList(ResetFormAction::create('cancel', 'Cancel')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true), FormAction::create('update', 'Update')->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true))); $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel '); // $contentComposite->addExtraClass('tinymce-codeeditor-field content'); $codeField->addExtraClass('nolabel stacked'); $form->unsetValidator(); $form->loadDataFrom($this); $form->addExtraClass('htmleditorfield-form htmleditorfield-codeform cms-dialog-content'); // $this->extend('updateLinkForm', $form); return $form; }
public function Form() { $fields = FieldList::create(TextField::create('Name', 'Name')->addExtraClass('col-sm-12 col-xs-12'), TextField::create('Email', 'Email')->addExtraClass('col-sm-12 col-xs-12'), TextField::create('Subject', 'Subject')->addExtraClass('col-sm-12 col-xs-12'), TextareaField::create('Message', 'Message')->addExtraClass('col-sm-12 col-xs-12')); $actions = FieldList::create(FormAction::create('Send', 'Send')->addExtraClass('btn btn-primary')); $requires = RequiredFields::create('Name', 'Email', 'Subject', 'Message'); $form = new Form($this, __FUNCTION__, $fields, $actions, $requires); $form->addExtraClass('col-sm-10 col-sm-offset-1 col-xs-12'); if ($formData = Session::get('ContactData')) { $form->loadDataFrom($formData); } return $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; }
/** * @param int|null $id * @param array|null $fields * @return \Form */ public function getEditForm($id = null, $fields = null) { $queues = $this->getQueues(); $gridField = new GridField('Queues', 'Queues', $queues, new GridFieldConfig_RecordEditor()); $dataComponent = $gridField->getConfig()->getComponentByType('GridFieldDataColumns'); $dataComponent->setDisplayFields(array('Name' => 'Name', 'Size' => 'Size')); $form = new Form($this, 'EditForm', new FieldList($gridField), new FieldList()); $form->addExtraClass('cms-edit-form cms-panel-padded center'); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); return $form; }
/** * @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'); // TODO Can't merge $FormAttributes in template at the moment $form->addExtraClass('cms-content center ss-tabset'); 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; }
/** * @param Controller $controller * @param string $back_url * @return Form */ public static function buildLoginForm(Controller $controller, $back_url = '') { if (!defined('OPENSTACKID_ENABLED') || OPENSTACKID_ENABLED == false) { $form = MemberAuthenticator::get_login_form($controller); return $form; } else { $back_url = OpenStackIdCommon::cleanBackUrl($back_url); $form = new Form($controller, 'OpenStackIdLoginForm', $fields = new FieldList(), $actions = new FieldList(array(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in"))))); $form->addExtraClass('form-fieldless'); $form->setFormAction("/Security/login?BackURL={$back_url}"); $form->setFormMethod('post'); return $form; } }
public function ReportForm() { $template = $this->data()->ReportTemplate(); if ($template && $template->ID && $this->data()->canEdit()) { $fields = new FieldSet(); $template->updateReportFields($fields); $fields->push(new TextField('Title', _t('ReportPage.NEW_TITLE', 'Title for generated reports'))); $actions = new FieldSet(new FormAction('save', _t('AdvancedReports.SAVE', 'Save')), new FormAction('preview', _t('AdvancedReports.PREVIEW', 'Preview')), new FormAction('generate', _t('AdvancedReports.GENERATE', 'Generate')), new FormAction('delete', _t('AdvancedReports.DELETE', 'Delete'))); $form = new Form($this, 'ReportForm', $fields, $actions); $form->loadDataFrom($template); $form->addExtraClass('ReportForm'); return $form; } return null; }
public function GenerateCouponsForm() { $fields = Object::create('OrderCoupon')->getCMSFields(); $fields->removeByName('Code'); $fields->removeByName('GiftVoucherID'); $fields->removeByName('SaveNote'); $fields->addFieldsToTab("Root.Main", array(NumericField::create('Number', 'Number of Coupons'), FieldGroup::create("Code", TextField::create("Prefix", "Code Prefix")->setMaxLength(5), DropdownField::create("Length", "Code Characters Length", array_combine(range(5, 20), range(5, 20)), OrderCoupon::config()->generated_code_length)->setDescription("This is in addition to the length of the prefix."))), "Title"); $actions = new FieldList(new FormAction('generate', 'Generate')); $validator = new RequiredFields(array('Title', 'Number', 'Type')); $form = new Form($this, "GenerateCouponsForm", $fields, $actions, $validator); $form->addExtraClass("cms-edit-form cms-panel-padded center ui-tabs-panel ui-widget-content ui-corner-bottom"); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $form->setHTMLID('Form_EditForm'); $form->loadDataFrom(array('Number' => 1, 'Active' => 1, 'ForCart' => 1, 'UseLimit' => 1)); return $form; }
/** * Returns a form with all languages with languages already used appearing first. * * @return Form */ function LangForm() { $member = Member::currentUser(); //check to see if the current user can switch langs or not if (Permission::checkMember($member, 'VIEW_LANGS')) { $field = new LanguageDropdownField('Locale', _t('CMSMain.LANGUAGEDROPDOWNLABEL', 'Language'), array(), 'SiteTree', 'Locale-English', singleton('SiteTree')); $field->setValue(Translatable::get_current_locale()); } else { // user doesn't have permission to switch langs // so just show a string displaying current language $field = new LiteralField('Locale', i18n::get_locale_name(Translatable::get_current_locale())); } $form = new Form($this->owner, 'LangForm', new FieldList($field), new FieldList(new FormAction('selectlang', _t('CMSMain_left.GO', 'Go')))); $form->unsetValidator(); $form->addExtraClass('nostyle'); return $form; }
public function Form() { if ($this->data()->canEdit()) { $classes = ClassInfo::subclassesFor('AdvancedReport'); array_shift($classes); //array_unshift($classes, ''); $classTitles = array('' => ''); foreach ($classes as $class) { $classTitles[$class] = Object::create($class)->singular_name(); } $fields = new FieldSet(new TextField('ReportName', _t('ReportHolder.REPORT_TITLE', 'Title')), new TextareaField('ReportDescription', _t('ReportHolder.REPORT_DESCRIPTION', 'Description')), new DropdownField('ReportType', _t('ReportHolder.REPORT_TYPE', 'Type'), $classTitles)); $actions = new FieldSet(new FormAction('createreport', _t('ReportHolder.CREATE_REPORT', 'Create'))); $form = new Form($this, 'Form', $fields, $actions, new RequiredFields('ReportName', 'ReportType')); $form->addExtraClass('newReportForm'); return $form; } }
/** * 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('SilvercartNewsletterRecipientsAdmin.Description', 'Please choose your export context and press the export button to download a CSV list of email recipients.'); $descriptionField = new SilvercartAlertInfoField('SilvercartProductImagesDescription', str_replace(PHP_EOL, '<br/>', $desc)); $exportContextField = new DropdownField('ExportContext', _t('SilvercartNewsletterRecipientsAdmin.ExportContext', 'Export context')); $exportContextField->setSource(array('0' => _t('SilvercartNewsletterRecipientsAdmin.ExportAll', 'Export all customers'), '1' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipients', 'Export all newsletter recipients'), '2' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithAccount', 'Export all newsletter recipients with customer account'), '3' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNewsletterRecipientsWithoutAccount', 'Export all newsletter recipients without customer account'), '4' => _t('SilvercartNewsletterRecipientsAdmin.ExportAllNonNewsletterRecipients', 'Export all non-newsletter recipients'))); $doExportButton = new InlineFormAction('do_newsletter_recipients_export', _t('SilvercartNewsletterRecipientsAdmin.DoExport', 'Export as CSV')); $doExportButton->includeDefaultJS(false); $doExportButton->setAttribute('data-icon', 'download-csv'); $fields->push($descriptionField); $fields->push($exportContextField); $fields->push($doExportButton); $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; }
function getEditForm($id = null, $fields = null) { $list = $this->getList(); $exportButton = new GridFieldExportButton('before'); $exportButton->setExportColumns($this->getExportFields()); $listField = GridField::create($this->sanitiseClassName($this->modelClass), false, $list, $fieldConfig = GridFieldConfig_RecordEditor::create($this->stat('page_length'))->removeComponentsByType('GridFieldFilterHeader')); // Validation if (singleton($this->modelClass)->hasMethod('getCMSValidator')) { $detailValidator = singleton($this->modelClass)->getCMSValidator(); $listField->getConfig()->getComponentByType('DynamicTemplateGridFieldDetailForm')->setValidator($detailValidator); } $form = new Form($this, 'EditForm', new FieldList($listField, new HeaderField(_t('DynamicTemplateAdmin.IMPORTTEMPLATE', 'Import template'), 3), new LiteralField('TemplateImportFormIframe', sprintf('<iframe src="%s" id="TemplateImportFormIframe" width="100%%" height="250px" border="0"></iframe>', $this->Link('DynamicTemplate/templateimport')))), new FieldList()); $form->addExtraClass('cms-edit-form cms-panel-padded center'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm')); // $form->setAttribute('data-pjax-fragment', 'DTEditForm'); $this->extend('updateEditForm', $form); // $this->getRequest()->addHeader('X-Pjax', 'CurrentForm'); return $form; }
/** * @return FieldSet */ function RootForm() { $memberList = new MemberTableField($this, "Members"); // unset 'inlineadd' permission, we don't want inline addition $memberList->setPermissions(array('edit', 'delete', 'add')); $fields = new FieldList(new TabSet('Root', new Tab('Members', singleton('Member')->i18n_plural_name(), $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 Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $this->Link('groupimport'))))), new HiddenField('ID', false, 0)); // Add roles editing interface if (Permission::check('APPLY_ROLES')) { $rolesCTF = new ComplexTableField($this, 'Roles', 'PermissionRole'); $rolesCTF->setPermissions(array('add', 'edit', 'delete')); $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles')); $rolesTab->push(new LiteralField('RolesDescription', '')); $rolesTab->push($rolesCTF); } $actions = new FieldList(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member'))); $this->extend('updateRootFormFields', $fields, $actions); $form = new Form($this, 'EditForm', $fields, $actions); $form->addExtraClass('cms-edit-form'); return $form; }