Copied to clipboard

Flag this post as spam?

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


  • alimac 182 posts 371 karma points
    Oct 06, 2020 @ 22:53
    alimac
    0

    Validation for custom backoffice forms

    I've created a custom section in my Umbraco back-end, and I'm trying to create some forms to capture data however I've been unable to fully understand how the umbraco directives work when it comes to validation.

    As an example, I'm trying to capture some basic data and save it using the following:

    <form name="myForm">
        <umb-property property="form.properties.name">
                <umb-property-editor model="form.properties.name"></umb-property-editor>
        </umb-property>
    
        <umb-button type="button"
                                label="Save"
                                button-style="success"
                                action="save()">
        </umb-button>
    

    And in my controller:

    $scope.form: {  
        properties: {    
                name: {
                        alias: 'name',
                        label: 'Display name',
                        description: '',
                        value: '',
                        view: 'textbox',
                        validation: {
                                mandatory: true
                        }
                }
        }
    

    I would have thought the 'validation' property would be where I can set the validation necessary on the property, however that doesn't seem to be the case. All that seems to do is highlight the property with a red asterix to indicate it's required rather than do any validation.

    I've taken a look at the backoffice documentation here however it's unfortunately lacking any code examples and I'm puzzled how this is supposed to work.

    I've looked at the other sections, particularly the create user form to see if I can pick anything up there but the only thing I've noticed is the 'valFormManager' directive which may be involved somehow.

    I've also tried the obvious things like putting ng-required on the editor and property but neither has done the trick.

    Is there any documentation for any of this? It's quite frustrating trying to work out how it's all supposed to work!

    Thanks

  • alimac 182 posts 371 karma points
    Oct 08, 2020 @ 07:53
    alimac
    0

    Just as an update, in case anyone finds themselves in a similar situation: I'm just having to write my forms manually as there doesn't seem to be sufficient documentation to use Umbraco's existing components.

Please Sign in or register to post replies

Write your reply to:

Draft