Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Nov 01, 2016 @ 17:19
    Amir Khan
    0

    Umbraco Forms Media Picker

    Is there any simple way to create a forms / media picker relationship where someone could pick from a list of media from a folder and the ID would be passed into a document type though the create Umbraco document workflow when the form was submitted?

  • Amir Khan 1287 posts 2744 karma points
    Nov 01, 2016 @ 18:25
    Amir Khan
    0

    So I was able to get this working on the front-end by borrowing the CheckBoxList field type view for this form. It seems like it is ignoring the ID of the option (which is what I want to pass to the document type), is this because a prevalue isn't set for that in the forms builder?

    Is there a way to just pass an value from a form field to a document type?

    Code below:

       @model Umbraco.Forms.Mvc.Models.FieldViewModel
    
    @{ 
        var i = 0;
        var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
    
        var media = umbracoHelper.TypedMedia(12195);
        var mediaFolder = media.Children;
    }
    
    <select class="checkboxlist image-picker" id="@Model.Id" name="@Model.Name">
    @foreach (var mediaImage in mediaFolder) {
        <option data-img-src="@mediaImage.Url" value="@mediaImage.Id" name="@mediaImage.Id" id="@mediaImage.Id">  Page 1  </option>
    
        i++;
    }
    </select>
    
    
    
    <script>
    $('.checkboxlist').imagepicker()
    

Please Sign in or register to post replies

Write your reply to:

Draft