Copied to clipboard

Flag this post as spam?

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


  • Harald Ulriksen 207 posts 249 karma points
    Oct 26, 2010 @ 12:53
    Harald Ulriksen
    0

    API not returning correct prevalues for Field

    Hi

    I'm trying to retrieve prevalues from a Field using the API based on http://our.umbraco.org/forum/umbraco-pro/contour/12438-Getting-prevalues-through-the-API

    using

     field.PreValueSource.Type.GetPreValues(field)

    returns prevalues from another prevalue of the same type. 

    I have a custom prevaluetype which takes an Xpath string and a node id as settings.
    I have configured 2 prevalues using this type, one called FOO and one called BAR with different xpath.
    I have 2 forms A and B. Form A has radiobuttons with prevalue FOO and form B has radiobuttons with prevalues from BAR. 

    I load form A using the API (and dispose of the form storage). I then try to access prevalues for the field using 

    Form.AllFields[7].PreValueSource.Type.GetPreValues(Form.AllFields[7]) 

    however this returns prevalues from BAR not FOO. 

    Checking PreValueSource.Name, Form.AllFields[7].PreValueSource.Name, returns FOO while Form.AllFields[7].PreValueSource.Type.FieldPreValueSource.Name returns BAR. 

    This is on Contour version 1.1.3

    Thanks,
    Harald 

  • Comment author was deleted

    Oct 26, 2010 @ 13:01

    Hi Harald,

    You should do an explicit load settings first,  f.PreValueSource.Type.LoadSettings(f.PreValueSource);

    Regards,
    Tim

  • Dan White 206 posts 510 karma points c-trib
    Nov 21, 2013 @ 22:33
    Dan White
    0

    Is there a way to load prevalues directly from the source without having to get them from a field?

  • Comment author was deleted

    Nov 22, 2013 @ 11:00

    Sure there is a prevalue storage

    Check Umbraco.Forms.Data.Storage.PrevalueSourceStorage

  • Dan White 206 posts 510 karma points c-trib
    Nov 25, 2013 @ 22:11
    Dan White
    0

    @Tim

    I tried messing around with that. It seems to always want me to pass in field though. I don't have a field to pass in.

        var pss = new Umbraco.Forms.Data.Storage.PrevalueSourceStorage();
        var ps = pss.GetPrevalueSource(new Guid("a693970f-c74e-4c1b-8130-f8f2fc5900f2")); // guid for PrevalueSource
        var pv = ps.Type.GetPreValues(WANTS A CONTOUR FIELD);
  • 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