This content does not apply to Commerce versions 14+.
Meta-field controls are rendered for custom fields. You can see examples of them when editing an entry or catalog nodes in the Catalog Management subsystem (legacy).
Meta-fields are rendered using default controls defined in the Admin/Apps/Core/MetaData/Controls/ folder. For example, the meta-field string is rendered using ShortStringControl.ascx.
You may have more specific data entry constraints than the default controls. For example, you want to add a custom status text field and ensure that only specific values are submitted. You want to keep it a simple string field in the database (to improve performance), but also want to prevent users from entering invalid data.
The simplest way to do this is to:
- Create a new custom user control (copy ShortStringControl.ascx).
- Change the textbox to a drop-down control with hard-coded values.
- Have the system use your control instead of the default one. To do that, the name of the control must match the name and metadata type of the meta-field to which you are mapping the control. See table and description below.
Another example is you want to override ImplementationStatus fields with a metadata field type of ShortString. You can do this as follows:
- Name the control ImplementationStatus.ShortStringControl.ascx.
- Create the ImplementationStatus meta-field as a Short String in the Catalog portion of the Administration tab.
- Add the field to a meta-class.
When you edit a catalog entry with this meta-class (containing the ImplementationStatus field), the field is represented with your custom control.
If using custom meta-fields (such as year) with search filters in places like the Shopping Options sidebar control, use the Float type instead of Decimal.
The engine lets you override how the meta-field is rendered for the scopes listed in the following table. The position reflects the order engine validating the controls, if the control exists, which renders the field and evaluation stops.
|Specific meta field name in particular meta class||MetaClassName.MetaFieldName.TypeName.ascx|
|Specific meta field name for all meta classes||MetaFieldName.TypeName.ascx|
|Specific meta class||MetaClassName.TypeName.ascx|
Updated 4 months ago