Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom Norwood 29 posts 60 karma points
    Jul 03, 2015 @ 16:54
    Tom Norwood
    0

    Cannot see FieldType Settings on RecordEventArgs

    Hi!

    Another issue on Umbraco.Forms 4.14. I'm trying to add settings to a FieldType to allow form designers to control how data is processed.

    I have a custom FieldType which has parameters:

            public class MyField : FieldType
            {                
                [Umbraco.Forms.Core.Attributes.Setting("MySetting",
                view = "TextField")]
                public string MySetting{ get; set; }
    
                public MyField ()
                {
                    Id = new Guid("2991EFCB-D6E6-4383-A627-D5A86F43C816");
                    Name = "My Field";
                    this.Description = "My Field";
                }
            }
    

    When I save a record I cannot see the setting in the RecordEventArgs object:

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                RecordStorage.RecordInserting += RecordInserting;
                base.ApplicationStarted(umbracoApplication, applicationContext);
            }
    
            private void RecordInserting(object sender, RecordEventArgs a)
            {
                var myFieldInfo =
                    from f in a.Record.RecordFields
                    let ft = f.Value.Field.FieldType as MyField
                    where ft != null
                    select new
                    {
                        f,
                        ft
                    };
                    foreach (var fieldInfo in myFieldInfo)
                    {
                        var mySetting == fieldInfo.ft.MySetting; // This is always null                                 
    
                    }
             }
    

    Any ideas?

    Tom

  • Tom Norwood 29 posts 60 karma points
    Jul 06, 2015 @ 10:12
    Tom Norwood
    0

    OK - I found it under: (RecordEventArgs a).Record.RecordFields[0].Value.Field.Settings[0]

    This seems like it is still a bug though as the type conversion

    let ft = f.Value.Field.FieldType as MyField

    doesn't seem to work here.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies