Skip to content

Unable to use custom form type #691

@HeerRik

Description

@HeerRik

Enhancement

Greetings,

I wish to create a custom datepicker addon, as the angular-schema-form-datepicker addon does not suit my needs.
I have tried understanding the docs on creating an addon, but I seem to miss something somewhere.

Expected behaviour

As in the docs, the custom field uses the bootstrap decorator, I figured I would not need to create my own decorator. I mainly copied most code, changing only the settings to fit my project.
I would expect the field to show up by now.

Actual behaviour

Unfortunately, the field does not show up, I also do not get any errors in the console, and the extension's .html is also not loaded.

Demo

Here is my controller:

var app = angular.module('testApp', ['schemaForm']);
app.controller('FormController', function($scope) {
    $scope.schema = {
        type: "object",
        properties: {
            name: {
                type: "string",
                minLength: 2,
                title: "Name",
                description: "Name or alias"
            },
            email: {
                type: "string",
                format: "email",
                title: "E-mail address",
                description: "Example: someone@example.com"
            },
            birthdate: {
                type: "date",
                title: "Birthdate",
                description: "Enter your birthdate"
            }
        }
    };
    $scope.form = [
        "*",
        {
            type: "submit",
            title: "Submit"
        }
    ];
});

And here is the code for the custom field type:

var app = angular.module('testApp');
app.config(function(schemaFormDecoratorsProvider, sfBuilderProvider) {
    schemaFormDecoratorsProvider.defineAddOn(
        'bootstrapDecorator',
        'date',
        '/client/fieldtypes/datepicker.html',
        sfBuilderProvider.stdBuilders);
});

And the fields html

<div>
    <label>{{form.title}}</label>
    <input sf-field-model schema-validate="form" type="text" placeholder="Hello, its me">
    <div sf-message="form.description"></div>
</div>

Thank you for your time, and I hope to get your response.

@json-schema-form/angular-schema-form-lead

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions