Change the section of a Custom Field
Hi all,
I've created a bunch of custom fields (back-end - event content) but I'm not able to group them in different sections. So all the custom fields stay at the bottom of the page which is ugly.
Do you know how to set the section for a custom field? Or even order my custom fields.
Thanks a lot.
Hi Jonathan,
To set sections as shown in the screenshot (EventsSections.png) and swap/change position up and down between the custom sections you have to go YourProject/App_Data/Sitefinity/Configuration and look trough
those configuration files for events that are created for you when you create event:
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendEdit
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendInsert
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendPreview
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendVersionPreview
in those configuration files you will see the custom fields you have created grouped in the CustomFieldsSection.
You can create your own custom section from there like:
<
sections
>
<
sections
displayMode
=
"Write"
wrapperTag
=
"Div"
name
=
"CustomFieldsSection1"
>
<
fields
>
<
field
rows
=
"1"
dataFieldName
=
"Test11"
wrapperTag
=
"Li"
title
=
"Test11"
example
=
"ins11"
fieldType
=
"Telerik.Sitefinity.Web.UI.Fields.TextField"
type:fieldType
=
"System.RuntimeType, mscorlib"
cssClass
=
""
hidden
=
"False"
fieldName
=
"Test11"
type:this
=
"Telerik.Sitefinity.Web.UI.Fields.Config.TextFieldDefinitionElement, Telerik.Sitefinity"
>
<
expandableDefinition
expandText
=
""
expanded
=
"True"
/>
<
validator
expectedFormat
=
"None"
maxLength
=
"0"
minLength
=
"0"
alphaNumericViolationMessage
=
"Non alphanumeric characters are not allowed."
currencyViolationMessage
=
"You have entered an invalid currency."
emailAddressViolationMessage
=
"You have entered an invalid email address."
integerViolationMessage
=
"You have entered an invalid integer."
interneturlviolationmessage
=
"You have entered an invalid URL."
maxLengthViolationMessage
=
"Too long"
maxValueViolationMessage
=
"Too big"
messageCssClass
=
"sfError"
messageTagName
=
"div"
minLengthViolationMessage
=
"Too short."
minValueViolationMessage
=
"Too small."
nonAlphaNumericViolationMessage
=
"Alphanumeric characters are not allowed."
numericViolationMessage
=
"You have entered an invalid number."
percentageViolationMessage
=
"You have entered an invalid percentage."
regularExpressionViolationMessage
=
"Invalid format."
requiredViolationMessage
=
"Required field."
usSocialSecurityNumberViolationMessage
=
"You have entered an invalid US social security number."
usZipCodeViolationMessage
=
"You have entered an invalid US ZIP code."
validateIfInvisible
=
"True"
resourceClassId
=
""
/>
</
field
>
</
fields
>
<
expandableDefinition
expandText
=
""
expanded
=
"True"
/>
</
sections
>
</
sections
>
Hi,
I would like to add another selection to the custom fields selections.
For example, a link field ('Telerik.Sitefinity.Web.UI.Fields.LinkField',)
How do I do it from the backend?
I thought when I am in the backend edit view,I can add a new custom field and in the field type, type in 'Telerik.Sitefinity.Web.UI.Fields.LinkField', but I get an error ." Cannot create an instance of Telerik.sitefinity.web.ui.fields.config.fielddefinition.element etc because it is an abstract class
Hello nana,
I suppose you mean " to add section to custom field". As mentioned when you create custom fields for Events ( or any other module that supports custom fields) those controls get added to Custom field section and you can add a new section Settings for Events --> Controls --> EventsBackend --> Views -->EventsBackendEdit --> Sections and Create a new Section. When you create the new section you can create the new custom field of the desired type Telerik.Sitefinity.Web.UI.Fields.LinkField under that section. You don't need to type "Telerik.Sitefinity.Web.UI.Fields.LinkField" because under the custom field section or your newly created you get a button at top that displays in a dropdown all available fields including Telerik.Sitefinity.Web.UI.Fields.LinkField.
Regards,
Stanislav Velikov
the Telerik team
The dropdown list I have does not contain a linkfield type.
Hello nana,
You can add it as described in my previous posts trough the configuration files.
<
field
rows
=
"1"
HideIfValue
=
""
id
=
""
dataFieldName
=
"CustomerRequest"
displayMode
=
"Write"
wrapperTag
=
"Li"
title
=
"http://somesite.com"
description
=
""
example
=
""
fieldType
=
"Telerik.Sitefinity.Web.UI.Fields.LinkField"
type:fieldType
=
"System.RuntimeType, mscorlib"
fieldVirtualPath
=
""
resourceClassId
=
""
cssClass
=
""
fieldName
=
"namefield"
type:this
=
"Telerik.Sitefinity.Web.UI.Fields.Config.TextFieldDefinitionElement, Telerik.Sitefinity"
>
<
expandableDefinition
expandText
=
""
expanded
=
"True"
/>
<
validator
expectedFormat
=
"None"
maxLength
=
"-1"
minLength
=
"-1"
regularExpression
=
""
regularExpressionSeparator
=
""
required
=
"False"
validateIfInvisible
=
"True"
/>
</
field
>
Thanks.
Hi Rafael,
Do you make the changes to all views?
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendEdit
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendInsert
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendPreview
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendVersionPreview
as mentioned in my first post. The changes are made in /App_Data/Sitefinity/Configuration.
Greetings,
Stanislav Velikov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks it's working for me!!!
Greetings
Guys,
I'm trying to add a field to an existing section - Zip Code to the Location section of the Events Module. I can add the fields using the approach defined here but it does not persist.
Any idea on why? and what I can do to make this work.
Thanks
Hello Kalisha,
The approach mentioned here is maent for adding custom fields only in the custom field section because all configurations to this section are saved in the configuration files.
To add a custom field to existing section go to settings for the module where you want to add the field.(I will use events as example).
Events->Controls->EventsBackend->Views->(Select a view you require)->Sections->Select section->
Fields and create new field.
Kind regards,
Stanislav Velikov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
We tried this, the field shows up but it's not persisted. We enter values for textfield type:
Datafield:ZipCode.PersistedValue
Display: Write
FieldName: ZipCode
css: sfShortField250
The text box appears in the Locations section and I can enter a value but the value isn't persisted since on edit of the content shows the value wasn't stored. Are we entering something wrong?
I am also moving my custom Zip Code field to the Locations section.
There is an easy way to do it using the config file:
EventsConfig.contentViewControls.EventsBackend.views.EventsBackendEdit.config
1. Create a new <sections> entry before the CustomFieldsSection <sections> entry and give it the name "LocationSection". Whatever you put in the section will be displayed in the locations section. If you feel nervous about manually creating the section in the config file, you could do it through the Sitefinity Advanced Settings as described by Stanislav and then go in and replace whatever field you created.
2. Cut and paste your fields from the custom section into the Locations section.
Your file will look something like this:
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
view
xmlns:config
=
"urn:telerik:sitefinity:configuration"
xmlns:type
=
"urn:telerik:sitefinity:configuration:type"
config:version
=
"4.2.1650.0"
viewName
=
"EventsBackendEdit"
>
<
sections
>
<
sections
name
=
"LocationSection"
>
<
fields
>
... this is where you can move the custom fields.
</
fields
>
</
sections
>
<
sections
displayMode
=
"Write"
wrapperTag
=
"Div"
name
=
"CustomFieldsSection"
>
<
fields
>
... this is where the custom fields are created initially.
</
fields
>
<
expandableDefinition
expanded
=
"True"
/>
</
sections
>
</
sections
>
</
view
>
Hello Kalisha,
Refer to this forum post where there is a discussion about how to persist the content of a custom field.
var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
var type = metaManager.CreateMetaType(typeof(ContentItem));
metaManager.SaveChanges();
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Antoine, thank's alot, that worked!
Hi,
I know this is an old post, but is there anyway to get the custom field to show up in the list of new "field" elements?
I have a common custom element, that I'd like to be able to add through the backend settings vs editing the config file directly. Edits directly in the config file, don't persist when changes are made to the dynamic modules.
I'd like to test to see if they persist when added directly through the backend settings interface.
Hello,
The list of elements is pulled from the built in fields types in Telerik.Sitefinity.dll assembly and as such the list can`t be updated to include a field from another assembly of a field present in the current site.
The problem where module builder configuration changes are not saved after making an update to any of the module fields or add new field is a feature that dynamically created modules don`t support, here is the feature request for preserving configuration changes.
Regards,
Stanislav Velikov
Telerik