Skip to content

Use "<ng-form>" instead of "<form>" to permit nesting, either by default or with an option #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quietlyconfident opened this issue Oct 14, 2014 · 2 comments

Comments

@quietlyconfident
Copy link

(This topic was was touched on in #98)

Briefly:

It would be nice if angular-schema-form ("ASF") constructed forms using <ng-form> instead of <form> so that ASF forms could be nested within other forms.

Background:

We have a form where the user "picks" a person out of an address book, and then enters a title for the person. The "picking" widget results in putting a URI into into the input field, so the model looks something like this:

physician = {
    'uri': '/some/uri/representing/a/person',
    'title': 'Town Dentist' }

On this model we have built a picker widget that gives the user a list of people, and returns the right URI to populate the URI field on the input element. Works great.

The problem is, we would like to be able to permit the user to create the contact with the same widget. Our use case is, you try to pick the person you want, but if they aren't there, you can create a record for them. In our existing widget (not implemented in ASF) we just put a 'new' button on the widget, and when you click it, a sub-form (using ng-form) appears inline. The user can enter the contact details, click "save", and that other model (the person) is validated against its own schema and the URL is again populated into the 'uri'.

This encourages DRY and permits maximum reusability because both the person CRUD form / schema as well as the outer "physician" type record could be implemented in ASF.

For the reasons discussed in #98, this does not seem possible (without changing the default templates) out of the box because ASF creates new forms using the

element which is not nestable.

@quietlyconfident quietlyconfident changed the title Use "<ng-form>" instead of "<form>" to permit nesting, either by default or with optionally Use "<ng-form>" instead of "<form>" to permit nesting, either by default or with an option Oct 14, 2014
@davidlgj
Copy link
Contributor

I don't think I understand your problem. Schema Form does not generate the form element. You put the sf-schema directive on some element and it generates a form fields inside it, and it can be any element.

#98 basically wanted sections to have an ng-form on them, and that would be very easy to do.

One of the design goals of schema form was that it should be easily extendable with new types (think form fields or widgets) in form of add-ons, there is some docs on it here: https://github.com/Textalk/angular-schema-form/blob/development/docs/extending.md

@quietlyconfident
Copy link
Author

You are correct, I did not understand that you could put the sf-schema on an element which was not a

. Closing the issue. Thanks for the education!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants