Accessing Settings Attribute values from MVC views
Hi,
Is it possible to access Umbraco.Forms.Core.Attributes.Setting values from the MVC view of a custom field type? For example, let's say you have a custom textfield FieldType, and you want to give the editor the ability to set the maxlength attribute per field in a form. You might have something like:
public class CustomInput : Umbraco.Forms.Core.FieldType { [Umbraco.Forms.Core.Attributes.Setting("Maxlength", control = "Umbraco.Forms.Core.FieldSetting.TextField")] public string MaxLength { get; set; }
public CustomInput() { this.Id = new Guid("0631C5F5-B8C1-4DDE-8166-04C6B4EC30F3"); this.Name = "Custom Text Field"; this.Description = "Custom Text Field";
Accessing Settings Attribute values from MVC views
Hi,
Is it possible to access Umbraco.Forms.Core.Attributes.Setting values from the MVC view of a custom field type? For example, let's say you have a custom textfield FieldType, and you want to give the editor the ability to set the maxlength attribute per field in a form. You might have something like:
How in MVC would I access the value an editor put in the MaxLength attribute?
Is this possible? I couldn't find any examples of such access in the documentation.
Thanks!
Comment author was deleted
Yeah
Model.AdditionalSettings.FirstOrDefault(x => x.Key == "MaxLength").Value
Tim,
Thanks for the quick response! But FieldViewModel doesn't seem to have AdditionalSettings defined. I'm getting a compiler error:
I'm using Contour 3.0.2. Is this maybe a newer feature than the version I'm running?
Thanks
Comment author was deleted
Yeah must be the case :) upgrade to 3.0.6 http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Installation/Upgrade
Upgrading to 3.0.6 fixed it. Thanks for the help!
is working on a reply...