Copied to clipboard

Flag this post as spam?

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


  • Nick 6 posts 96 karma points
    Sep 05, 2018 @ 00:05
    Nick
    0

    Adding an additional field to Umbraco Form questions

    Hi

    I was wondering is it possible to add an additional field on question?

    I want to add another text field on all my question.

    Nick

  • Nick 6 posts 96 karma points
    Sep 13, 2018 @ 02:19
    Nick
    100

    Yes it is possible Nick! Inside the Umbraco.Form.js you can add additional fields in the setting section of questions.

    You need to modify the following code:

        formResource.getPrevalueSources().then(function (resp) {
            vm.prevaluesources = resp.data;
    
            formResource.getAllFieldTypesWithSettings().then(function (resp) {
                for (var i = 0; i < resp.data.length; i++) {
                    // add new setting here
                    resp.data[i].settings.push({ name: "Extra Setting", alias: "extraSetting", description: "Enter in your message", prevalues: Array(1), view: "/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/TextField.html" });
                }
    
                vm.fieldtypes = resp.data;
                vm.ready = true;
            });
        });
    
    
    
    
    
        function openFieldTypePickerOverlay(field) {
    
            vm.focusOnMandatoryField = false;
    
            vm.fieldTypePickerOverlay = {
                view: "/app_plugins/UmbracoForms/Backoffice/Form/overlays/fieldtypepicker/field-type-picker.html",
                title: "Choose answer type",
                hideSubmitButton: true,
                show: true,
                submit: function(model) {
                    //add new setting here
                    model.fieldType.settings.push({ name: "Extra Setting", alias: "extraSetting", description: "Enter in your message", prevalues: Array(1), view: "/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/TextField.html" });
    
                    formService.loadFieldTypeSettings(field, model.fieldType);
    
                    // this should be removed in next major version
                    field.removePrevalueEditor = true;
    
                    vm.fieldTypePickerOverlay.show = false;
                    vm.fieldTypePickerOverlay = null;
                }
            };
    
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft