-
Notifications
You must be signed in to change notification settings - Fork 300
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
Two different forms, one model #244
Comments
Same as #205. Lets keep talking there, please. |
I opened this issue again due to a wrong understanding of it. Anyway, I'm taking care of your feature man — it makes sense a lot. |
To validate a subset of the attributes is necessary to pass an array to isValid function:
What can be implemented is e.g. an option to be passed when |
@blikblum It's time to automate this process. We'll pass an option to check the form based on its fields and then we validate what's within. |
I think this feature could be implemented in two steps, so it can be flexible and non invasive:
It's important to keep things not coupled because there's no uniform way to store/retrieve attribute names in forms. This schema would allow, e.g., have a function that gets the attributes from |
@blikblum I see your proposal being implicit and explicit — which is the same thing I thought. Implicit when there's something in the form our users don't want to validate and explicit when the entire form, according to the right field names, should be validated. 👍 We should to go further discussing how we'll design these solutions. Please, let's talk faster on Gitter. |
I +1 this feature. We have a very similar requirement in our system where the same model in a given single page application might need different validations depending on where it is being loaded in the flow. We had to fork the repo and ended up making a _validations object on the model that is a map of validations given some key (because the same single page app can load different validations on the given model). If a key was set, and _validations existed, we loaded that set over the standard model.validation, otherwise we loaded the default. |
@SomethingSexy Just wondering, would setting |
@platinumazure we thought about that but for our case (which might be very specific to us) we had to determine the configuration from outside of the model. We have some components that can be reused with the same view and same model instance but need to load different configurations at run-time. |
I am wondering if it possible to pass in your validation sets optionally instead of always pulling them from the model itself? When you are calling preValidate, isValid or validate, you could optionally pass in your validation. |
The other questions that are similar to this one don't seem to address this; forgive me if I'm misunderstanding.
If I have a
User
model and alogin
view as well as asignup
view, how do I makepassword2
required on thesignup
view but not on thelogin
view? My model'svalidation
object haspassword2
set torequired: true
and it appears to be applying this to both views, even if thelogin
view doesn't have apassword2
field to begin with.I'm binding via
Backbone.Validation.bind(this);
in the view'sinitialize()
method.The text was updated successfully, but these errors were encountered: