Skip to content
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

Multiple Field with the Same Name on a Page #310

Open
matt-holmes opened this issue Sep 19, 2015 · 2 comments
Open

Multiple Field with the Same Name on a Page #310

matt-holmes opened this issue Sep 19, 2015 · 2 comments

Comments

@matt-holmes
Copy link

I have a situation where a user might be signing up for him/herself + guests, which creates multiple fields with the same field name. It would be nice if we could pass the model object to the valid/invalid functions from the isValid() and validate() functions. This would allow me to use the model's cid to create a unique class on each field and target them from within the pluggin.

@platinumazure
Copy link

You should probably use a collection and set of views there, so each model
can validate itself and not know about the others. Or am I misunderstanding?
On Sep 19, 2015 10:44 AM, "matt-holmes" [email protected] wrote:

I have a situation where a user might be signing up for him/herself +
guests, which creates multiple fields with the same field name. It would be
nice if we could pass the model object to the valid/invalid functions from
the isValid() and validate() functions. This would allow me to use the
model's cid to create a unique class on each field and target them from
within the pluggin.


Reply to this email directly or view it on GitHub
#310.

@matt-holmes
Copy link
Author

I have a unique setup so let me back up.. We've built a CMS that doubles as a rest API and serves up my site. Every section and field on the page are dynamically generated, which is what we use to build the views. Also, as every field gets built, I push the validation rules onto the user model from the field meta data passed in on the API. Every time a user interacts with one of these fields we set our user models with an attribute as the same name as the field name. Then when saving we save our user models. So, I've set it up to loop thru each user model and validate those attributes (not the attributes from the view).

So, in order to get this to work, I've removed the view object from the callbacks (since I'm validating my user object instead of the view). But then the final problem comes when highlighting the problem field.

I realize this is a major outlier, but it would be nice to get the model that I'm validating passed in so I can use some of those additional attributes.

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