Skip to content

Broadcast schemaForm.error for a specific form #655

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
LeonardoGentile opened this issue Mar 23, 2016 · 5 comments
Closed

Broadcast schemaForm.error for a specific form #655

LeonardoGentile opened this issue Mar 23, 2016 · 5 comments

Comments

@LeonardoGentile
Copy link
Contributor

Similar to #589 broadcast an schemaForm.error.name could not be enough when we have multiple forms. One solution could be to create multiple controllers (one for form) but IMO is not the best solution.

Any plan to pass the form name on broadcast in order to Inject the right errors in the right form?

If not, any hint about a possible solution?

@Anthropic
Copy link
Member

I personally do have a different controller per form. With Angular 2 and the shift to components this is likely to be even more common I would expect. However I will keep it in mind when we start refactoring the validations into their own component/repo.

@LeonardoGentile
Copy link
Contributor Author

@Anthropic thanks. Could you give me a hint what/where to modify so I will start doing it by myself?

About the discussion on Angular 2, isn't it the other way around? They are trying to get rid of controllers, and adding a controller for each form doesn't seem to be ideal.

Also, I guess one of the reasons to use schema-form is to avoid code repetition in html templates and DOM elements. Let's say I have a list of forms that is coming from the server so I don't know in advance how many forms I have to create. I would use an ng-repeat:

<form ng-repeat="form in formList"
  sf-schema="form.schema" 
  sf-form="form.formDef" 
  sf-model="model"></form>

attaching the right controller for the right form could be kind of tricky.
Also if I have 100 form definitions it means I should create 100 controllers just to capture the right broadcasted schemaForm.error.name for the right form. Doesn't seems an option to me

LeonardoGentile added a commit to LeonardoGentile/angular-schema-form that referenced this issue Mar 25, 2016
LeonardoGentile added a commit to LeonardoGentile/angular-schema-form that referenced this issue Mar 25, 2016
* feature-655:
  Pass optional form name when broadcast error (json-schema-form#655)
@LeonardoGentile
Copy link
Contributor Author

I provided a PR if interested #656

@Anthropic
Copy link
Member

@LeonardoGentile thanks for that, I will take a look this week, I am not doing the release this weekend as I need some questions answered first from the lead developer who is a notoriously busy man in demand, so plenty of time for this to make it in :)

@Anthropic
Copy link
Member

Released as part of 0.8.13

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

No branches or pull requests

2 participants