Copied to clipboard

Flag this post as spam?

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


  • Lazau Florin 74 posts 210 karma points
    Mar 11, 2017 @ 12:07
    Lazau Florin
    0

    Umbraco forms - disable answer type

    Hi Guys,

    I would like to remove File Upload form my answer type options.

    Can you help me?

    Thanks, Florin

  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    Mar 13, 2017 @ 07:49
    Dennis Adolfi
    103

    Hi Lazau.

    Wow, that's a new one. Most questions regarding fieldtype is usually about adding fieldtypes, not removing. For all I know, there is not built in configuration for removing the standard fieldtypes without some "hacky" coding. It does sound however like a useful config that would be nice to have in the /App_Plugins/UmbracoForms/UmbracoForms.config file, something like:

    <setting key="DisableFieldTypes" value="fileUpload,somethingelse" />
    

    But this is however not a valid setting at the monent. Maybe you could add it as a feature request on http://issues.umbraco.org? (Make sure to label you post 'Feature Request' and not 'Bug')

    However, if this is something that you really want right now, here is the hacky solution (note, I dont recommend this since future Umbraco Forms upgrades might override this, but I do understand that sometimes one needs to take extreme actions to fit a clients need):

    Find this file: /App_Plugins/UmbracoForms/Backoffice/Form/overlays/fieldtypepicker/field-type-picker.html.

    In the LI element repeater, add the following angular conditional class (line 22).

    ng-class="{hide: fieldType.name == 'File upload'}"
    

    This will add the class 'hide' to the field type File Upload, making it not visible. See animation:

    enter image description here

    As I said, this is not a pretty solution, but it works. A setting in a configuration file would be a lot prettier or some way of removing fieldtypes by adding a custom class of some sort could also work, but for all I know, thats not possible.

    All the best / Dennis

  • Lazau Florin 74 posts 210 karma points
    Mar 13, 2017 @ 10:18
    Lazau Florin
    2

    Hi Dennis,

    Thanks a lot for answering, and for answering in this manner (like the super complete answer).

    I need this "hacky" code because of this

    Have a nice day!

    Florin

  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    Mar 13, 2017 @ 13:02
    Dennis Adolfi
    0

    No problem Florin!

    Glad I could help!

    Take care and have a great day!

    / Dennis

  • jeffrey@umarketingsuite.com 350 posts 1671 karma points MVP 4x c-trib
    Mar 14, 2017 @ 07:19
    jeffrey@umarketingsuite.com
    1

    Hi Florin,

    another option could be installing our package Forms On Steroids (https://our.umbraco.org/projects/backoffice-extensions/umbraco-forms-on-perplex-steroids/) that has this option configurable in a config-file. Per datatype you can decide whether to have it available or not

    Cheerio,

    Jeffrey

  • Lazau Florin 74 posts 210 karma points
    Mar 14, 2017 @ 07:23
    Lazau Florin
    0

    Hi Jeffrey,

    Wow...awesome package.

    Thanks a lot!

    Florin

  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    Mar 14, 2017 @ 07:30
    Dennis Adolfi
    0

    Ah, brilliant. :)

    I do love "Umbraco Forms on Perplex Steroids" and use it in most of the solutions I build, however i've seem to have missed this feature.

    Sometimes it feels like everytime a question starts with "Can I do ... with Umbraco Forms?", 9/10 time the answer is "Yes, if you install Perplex Steroids". :)

    Thank you for an awesome package Jeffrey!

  • jeffrey@umarketingsuite.com 350 posts 1671 karma points MVP 4x c-trib
    Mar 14, 2017 @ 07:33
    jeffrey@umarketingsuite.com
    1

    Haha Florin and Dennis,

    thanks for making me wake up with a smile on my face!

    Spread the word ;)!

  • Lazau Florin 74 posts 210 karma points
    Mar 14, 2017 @ 07:35
    Lazau Florin
    1

    Will do :)

  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    Mar 14, 2017 @ 07:36
    Dennis Adolfi
    0

    You got it! :)

  • Markus Johansson 1661 posts 4735 karma points c-trib
    Mar 11, 2020 @ 12:17
    Markus Johansson
    1

    Hi Guys!

    Since this was posted before Umbraco 8 I figured I'll share my findings in regards to Umbraco Forms 8+.

    In the updated version they use "BuilderCollections" which makes it possible to modify Workflows, FieldTypes and more during Composition.

    Ie:

    [ComposeAfter(typeof(UmbracoFormsComposer))]
    public class MySiteComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            // Workflows
            composition.WithCollectionBuilder<WorkflowCollectionBuilder>().Clear();
            composition.WithCollectionBuilder<WorkflowCollectionBuilder>().Add<ContactTargetWorkflow>();
    
            // Field types
            composition.WithCollectionBuilder<FieldCollectionBuilder>().Exclude<Recaptcha2>();
        }
    }
    

    When I first tested this my Composer did not have the ComposeAfter-attribute, but after adding this it worked fine.

    [ComposeAfter(typeof(UmbracoFormsComposer))]
    

    Apart of these two collection there's also some other UmbracoForms-collections that can be modified during Composition:

    composition.WithCollectionBuilder<DataSourceCollectionBuilder>()
    composition.WithCollectionBuilder<ExportCollectionBuilder>()
    composition.WithCollectionBuilder<FieldPreValueSourceCollectionBuilder>()
    composition.WithCollectionBuilder<RecordSetActionCollectionBuilder>()
    

    There is also an issue for this on Github: https://github.com/umbraco/Umbraco.Forms.Issues/issues/61

    Hope this helps anyone trying to accomplish the this.

  • Chris Evans 114 posts 285 karma points c-trib
    Mar 12, 2020 @ 01:13
    Chris Evans
    0

    This works like a charm - thank you so much! Have wanted this feature forever.

  • iNETZO 93 posts 412 karma points
    Jun 22, 2020 @ 19:56
    iNETZO
    0

    Hi Markus,

    Thank you very much for this! Do you also know if it is possible to set the the "HideField"-property of the build-in fieldtypes to true? I want t hide all buildin fieldtypes but they are already used in some existing forms.

    Best regards,

    iNETZO

  • Markus Johansson 1661 posts 4735 karma points c-trib
    Jun 22, 2020 @ 21:03
    Markus Johansson
    0

    Hi!

    Hmm, I really don’t know, maybe it would work to create classes that inherits from them add these to the collections and remove the original once. I really don’t have a good answer. Sorry.

    Cheers!

Please Sign in or register to post replies

Write your reply to:

Draft