本文整理汇总了PHP中FieldList::dataFieldByName方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::dataFieldByName方法的具体用法?PHP FieldList::dataFieldByName怎么用?PHP FieldList::dataFieldByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldList
的用法示例。
在下文中一共展示了FieldList::dataFieldByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->insertBefore(new Tab('MembershipDetails', 'Membership Details'), 'Main');
//move first and ;astname
$fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('FirstName'));
$fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('Surname'));
$fields->addFieldToTab('Root.MembershipDetails', $fields->dataFieldByName('Email'));
$fields->addFieldToTab('Root.MembershipDetails', $region = DropdownField::create('RegionID', 'Region', Region::get()->map('ID', 'Title')));
$region->setEmptyString(' ');
$fields->addFieldToTab('Root.MembershipDetails', DropdownField::create('MembershipStatus', 'Membership Status', $this->owner->dbObject('MembershipStatus')->enumValues()));
$fields->addFieldToTab('Root.MembershipDetails', $expiry = DateField::create('ExpiryDate'));
$fields->addFieldToTab('Root.MembershipDetails', DropdownField::create('Discount', 'Discount', $this->owner->dbObject('Discount')->enumValues()));
$fields->addFieldToTab('Root.MembershipDetails', $discountExpiry = DateField::create('DiscountExpiryDate'));
$fields->addFieldToTab('Root.MembershipDetails', $joined = DateField::create('JoinedDate'));
$fields->addFieldToTab('Root.MembershipDetails', TextareaField::create('NotesForMember'));
if ($this->owner->MembershipStatus !== "Not applied") {
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('MemberNumber'));
}
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('HomePhone'));
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('WorkPhone'));
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('MobilePhone'));
$fields->addFieldToTab('Root.MembershipDetails', TextareaField::create('Address'));
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('Occupation'));
$fields->addFieldToTab('Root.MembershipDetails', TextField::create('BirthDate'));
$expiry->setConfig('showcalendar', true);
$expiry->setConfig('showdropdown', true);
$expiry->setConfig('dateformat', 'dd-MM-YYYY');
$discountExpiry->setConfig('showcalendar', true);
$discountExpiry->setConfig('showdropdown', true);
$discountExpiry->setConfig('dateformat', 'dd-MM-YYYY');
$joined->setConfig('showcalendar', true);
$joined->setConfig('showdropdown', true);
$joined->setConfig('dateformat', 'dd-MM-YYYY');
}
示例2: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->removeFieldFromTab("Root.Main", "MenuTitle");
$fields->addFieldToTab('Root.Main', new LiteralField("manage", "<a style='margin-bottom:15px' class='backlink ss-ui-button cms-panel-link ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary ui-state-hover ui-state-active' data-icon='back' href='" . Director::absoluteBaseURL() . "admin/pages/edit/show/" . $this->owner->Parent()->ID . "' role='button' aria-disabled='false'><span class='ui-button-icon-primary ui-icon btn-icon-back'></span><span style='padding-left:5px' >\n\t\t\tManage Posts\n\t\t</span></a>"), 'Title');
$image = $fields->dataFieldByName("FeaturedImage");
if ($image) {
$image->setFolderName('Managed/BlogPosts/Featured');
$image->setCanPreviewFolder(false);
}
// Get config options for using tags / categories
$use_categories = Config::inst()->get("Blog", 'use_categories');
$use_tags = Config::inst()->get("Blog", 'use_tags');
$use_featured_image = Config::inst()->get("Blog", 'use_featured_image');
// Adds message below tags/categories fields if none exist telling user where to create them
if (!$this->owner->Parent()->Categories()->count() && $use_categories) {
$cats = $fields->dataFieldByName("Categories");
$cats->setRightTitle("You must first add categories via the <strong>Blog Options</strong> tab on the <a href='admin/pages/edit/show/" . $this->owner->Parent()->ID . "'>main Blog page</a>.");
}
if (!$this->owner->Parent()->Tags()->count() && $use_tags) {
$cats = $fields->dataFieldByName("Tags");
$cats->setRightTitle("You must first add tags via the <strong>Blog Options</strong> tab on the <a href='admin/pages/edit/show/" . $this->owner->Parent()->ID . "'>main Blog page</a>.");
}
// Hide tags/categories fields if turned off in config
if (!$use_categories) {
$fields->removeByName("Categories");
}
if (!$use_tags) {
$fields->removeByName("Tags");
}
if (!$use_featured_image && !$this->owner->FeaturedImage()->exists()) {
$fields->removeFieldFromTab("Root.Main", "FeaturedImage");
}
// Need to add proper support for this, removing for now, needs to play nicely with my "Disply Full Posts" option:
$fields->removeFieldFromTab("Root.Main", "CustomSummary");
}
示例3: setError
/**
* @param string $message
* @param string $messageType
*/
public function setError($message, $messageType)
{
// show the manual fields
$this->manualToggle->setValue('1');
$name = $this->getName();
$field = $this->manualFields->dataFieldByName("{$name}[{$messageType}]");
if ($field) {
$field->setError($message, 'validation');
}
}
示例4: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->dataFieldByName('Title')->setTitle(_t('Linkable.TITLE', 'Link Text'));
$fields->dataFieldByName('OpenInNewWindow')->hideIf("Type")->isEqualTo("File")->end();
/** @var TextField $seoText */
$fields->addFieldToTab('Root.Main', $seoText = TextField::create('LinkSeoText', _t('Linkable.SEOTEXT', 'SEO Title Attribute')), 'Type');
$seoText->setDescription('Optional. Will be equal to Link Text if left blank');
$fields->addFieldToTab('Root.Main', $forceDownload = CheckboxField::create('ForceDownload', _t('Linkable.FORCEDOWNLOAD', 'Force user to download file')));
$forceDownload->displayIf('Type')->isEqualTo("File")->end();
$fields->removeByName('OwningPageID');
}
示例5: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$field = $fields->dataFieldByName('MetaTitle');
if ($field) {
$field->setAttribute('data-length', self::$meta_title_length);
}
$field = $fields->dataFieldByName('MetaDescription');
if ($field) {
$field->setAttribute('data-length', self::$meta_description_length);
}
return $fields;
}
示例6: updateCMSFields
function updateCMSFields(FieldList $fields)
{
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
$subsitesMap = array();
if ($subsites && $subsites->Count()) {
$subsitesMap = $subsites->map('ID', 'Title');
unset($subsitesMap[$this->owner->SubsiteID]);
}
// Master page edit field (only allowed from default subsite to avoid inconsistent relationships)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;
if ($isDefaultSubsite && $subsitesMap) {
$fields->addFieldToTab('Root.Main', new DropdownField("CopyToSubsiteID", _t('SiteTreeSubsites.CopyToSubsite', "Copy page to subsite"), $subsitesMap, ''));
$fields->addFieldToTab('Root.Main', $copyAction = new InlineFormAction("copytosubsite", _t('SiteTreeSubsites.CopyAction', "Copy")));
$copyAction->includeDefaultJS(false);
}
// replace readonly link prefix
$subsite = $this->owner->Subsite();
$nested_urls_enabled = Config::inst()->get('SiteTree', 'nested_urls');
if ($subsite && $subsite->ID) {
$baseUrl = Director::protocol() . $subsite->domain() . '/';
$baseLink = Controller::join_links($baseUrl, $nested_urls_enabled && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null);
$urlsegment = $fields->dataFieldByName('URLSegment');
$urlsegment->setURLPrefix($baseLink);
}
}
示例7: updateCMSFields
/**
* @param FieldList $fields
*/
public function updateCMSFields(FieldList $fields)
{
// Redo LDAP metadata fields as read-only and move to LDAP tab.
$ldapMetadata = array();
$fields->replaceField('IsImportedFromLDAP', $ldapMetadata[] = new ReadonlyField('IsImportedFromLDAP', _t('LDAPMemberExtension.ISIMPORTEDFROMLDAP', 'Is user imported from LDAP/AD?')));
$fields->replaceField('GUID', $ldapMetadata[] = new ReadonlyField('GUID'));
$fields->replaceField('IsExpired', $ldapMetadata[] = new ReadonlyField('IsExpired', _t('LDAPMemberExtension.ISEXPIRED', 'Has user\'s LDAP/AD login expired?')));
$fields->replaceField('LastSynced', $ldapMetadata[] = new ReadonlyField('LastSynced', _t('LDAPMemberExtension.LASTSYNCED', 'Last synced')));
$fields->addFieldsToTab('Root.LDAP', $ldapMetadata);
if ($this->owner->IsImportedFromLDAP) {
// Transform the automatically mapped fields into read-only.
$mappings = Config::inst()->get('Member', 'ldap_field_mappings');
foreach ($mappings as $ldap => $ss) {
$field = $fields->dataFieldByName($ss);
if (!empty($field)) {
// This messes up the Member_Validator, preventing the record from saving :-(
// $field->setReadonly(true);
$field->setTitle($field->Title() . _t('LDAPMemberExtension.IMPORTEDFIELD', ' (imported)'));
}
}
// Display alert message at the top.
$message = _t('LDAPMemberExtension.INFOIMPORTED', 'This user is automatically imported from LDAP. ' . 'Manual changes to imported fields will be removed upon sync.');
$fields->addFieldToTab('Root.Main', new LiteralField('Info', sprintf('<p class="message warning">%s</p>', $message)), 'FirstName');
}
}
示例8: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$logo = $fields->dataFieldByName('Logo');
$fields->removeByName('ParentID');
$fields->removeByName('Sort');
$fields->insertAfter($logo, 'Title');
}
示例9: updateCMSFields
public function updateCMSFields(\FieldList $fields)
{
if (!$this->owner->Deleted) {
$fields->removeByName('Deleted');
$fields->removeByName('DeletedByID');
} else {
$Deleted = $fields->dataFieldByName('Deleted');
$DeletedByID = $fields->dataFieldByName('DeletedByID');
if ($Deleted) {
$fields->makeFieldReadonly('Deleted');
}
if ($DeletedByID) {
$fields->makeFieldReadonly('DeletedByID');
}
}
}
示例10: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
if (!$fields->dataFieldByName('ActivateMinisite')) {
$fields->addFieldToTab('Root.Main', new FieldGroup("Minisite Layout", array(new CheckboxField('ActivateMinisite', 'Activate'))), "Title");
}
return $fields;
}
示例11: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$subsites = class_exists('Subsite');
$onMainSite = TRUE;
$currentSubsiteID = 0;
$currentSiteConfig = SiteConfig::current_site_config();
if ($subsites) {
$currentSubsiteID = Subsite::currentSubsiteID();
if ($currentSubsiteID) {
$onMainSite = FALSE;
}
$mainSiteConfig = SiteConfig::get()->filter('SubsiteID', 0)->first();
} else {
$mainSiteConfig = $currentSiteConfig;
}
// Add mailblock CMS fields.
if (Permission::check('MANAGE_MAILBLOCK') && ($mainSiteConfig->getField('MailblockApplyPerSubsite') || $onMainSite)) {
$enabled = $currentSiteConfig->getField('MailblockEnabled');
$tabSet = new TabSet('Mailblock', $settingsTab = $this->basicSettingsFields(), $advancedSettingsTab = $this->advancedSettingsFields($onMainSite, $currentSubsiteID), $testTab = $this->testEmailCMSFields($enabled));
$fields->addFieldToTab('Root', $tabSet);
$hiddenFields = array('MailblockEnabledOnLive', 'MailblockOverrideConfiguration', 'MailblockRecipients', 'MailblockWhitelist');
if ($subsites && $currentSubsiteID == 0) {
$hiddenFields[] = 'MailblockApplyPerSubsite';
}
foreach ($hiddenFields as $field) {
$field = $fields->dataFieldByName($field);
$field->displayIf('MailblockEnabled')->isChecked();
}
}
}
示例12: updateCMSFields
/**
* standard SS method
* @var Array
**/
public function updateCMSFields(FieldList $fields)
{
//separate MetaTitle
if (Config::inst()->get("MetaTagsContentControllerEXT", "use_separate_metatitle") == 1) {
$fields->addFieldToTab('Root.Main.Metadata', $allowField0 = new TextField('MetaTitle', _t('SiteTree.METATITLE', 'Meta Title')), "MetaDescription");
$allowField0->setRightTitle(_t("SiteTree.METATITLE_EXPLANATION", "Leave this empty to use the page title"));
}
//info about automation
$fields->addFieldToTab('Root.Main.Metadata', $allowField1 = new CheckboxField('AutomateMetatags', _t('MetaManager.UPDATEMETA', 'Automatically update Meta Description and Navigation Label? ')));
$automatedFields = $this->updatedFieldsArray();
$updatedFieldString = "";
if (count($automatedFields)) {
$updatedFieldString = "" . _t("MetaManager.UPDATED_EXTERNALLY", "Based on your current settings, the following fields will be automatically updated at all times") . ": <em>" . implode("</em>, <em>", $automatedFields) . "</em>.";
foreach ($automatedFields as $fieldName => $fieldTitle) {
$oldField = $fields->dataFieldByName($fieldName);
if ($oldField) {
$newField = $oldField->performReadonlyTransformation();
//$newField->setTitle($newField->Title());
$newField->setRightTitle(_t("MetaTags.AUTOMATICALLY_UPDATED", "Automatically updated when you save this page (see metadata settings)."));
$fields->replaceField($fieldName, $newField);
}
}
}
$fields->removeByName('ExtraMeta');
$linkToManager = Config::inst()->get("MetaTagCMSControlPages", "url_segment") . '/';
$fields->addFieldToTab('Root.Main.Metadata', new LiteralField("LinkToManagerHeader", "<blockquote style='padding-left: 12px;'>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tOpen the Meta Tag Manager to\n\t\t\t\t\t\t<a href=\"{$linkToManager}\" target=\"_blank\">Review and Edit</a>\n\t\t\t\t\t\tthe Meta Data for all pages on this site.\n\t\t\t\t\t\tAlso make sure to review the general settings for\n\t\t\t\t\t\t<a href=\"/admin/settings/\">Search Engines</a>. {$updatedFieldString}\n\t\t\t\t\t</p>\n\t\t\t\t</blockquote>"));
if ($this->owner->URLSegment == RootURLController::get_default_homepage_link()) {
$newField = $fields->dataFieldByName('URLSegment');
$newField->setRightTitle("Careful: changing the URL from 'home' to anything else means that this page will no longer be the home page");
$fields->replaceField('URLSegment', $newField);
}
return $fields;
}
示例13: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$grid = $fields->dataFieldByName('Members');
if ($grid) {
$grid->getConfig()->removeComponentsByType('GridFieldDeleteAction');
$grid->getConfig()->addComponent(new MemberGroupDeleteAction(true));
}
}
示例14: updateCMSFields
/**
* Updates the CMS fields adding the fields defined in this extension
* @param {FieldList} $fields Field List that new fields will be added to
*/
public function updateCMSFields(FieldList $fields)
{
$urlSegmentField = $fields->dataFieldByName('URLSegment');
if ($urlSegmentField) {
$baseLink = Controller::join_links(Director::absoluteBaseURL(), (Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL') ? $this->owner->Locale : i18n::get_lang_from_locale($this->owner->Locale)) . '/', SiteTree::config()->nested_urls && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null);
$urlSegmentField->setURLPrefix($baseLink);
}
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-translatablerouting,代码行数:12,代码来源:MultilingualSiteTreeExtension.php
示例15: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$owner = $this->owner;
if (isset($owner::$db_descriptions)) {
foreach ($owner::$db_descriptions as $field => $description) {
$fields->dataFieldByName($field)->setDescription($description);
}
}
}