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

List validation #483

Open
MeterSoft opened this issue Jan 12, 2016 · 24 comments
Open

List validation #483

MeterSoft opened this issue Jan 12, 2016 · 24 comments

Comments

@MeterSoft
Copy link

How i can run validation by nested model schema?

schema: {
firstName: { type: 'Text', validators: [{ type: 'required', message: 'Can not be blank' }] },
phoneNumbers: {
type: 'List', itemType: 'NestedModel', model: infocus.PhoneNumber, title: ''
}
}

schema: {
type: { type: 'Select', options: ['SIP', 'Phone', 'H123'] },
number: { type: 'Text', validators: [{ type: 'required', message: 'Can not be blank' }, { type: 'email', message: 'Invalid number' }] }
}

but when i run form.commit() it validate only main model

@exussum12
Copy link
Collaborator

Use master if possible master has support for it, it was added here #414

@MeterSoft
Copy link
Author

It works only if use form.validate() and it return
_others: [[Object { name="firstName", message="Can not be blank"}, Object { name="number", message="Can not be blank"}]]

but if i use form.commit() it validate only main form and return error related this

I have a list of phone numbers but all not have unique id. i think it should add backbone view id and errors should return like this [{"number_view1": "can not be blank"}, {"number_view2": "can not be blank"}] and add this error to own number

Also all list have id like undefined_number

@exussum12
Copy link
Collaborator

Can you give an example ? Im pretty sure i fixed that issue too

@MeterSoft
Copy link
Author

exussum12 added a commit to exussum12/backbone-forms that referenced this issue Jan 17, 2016
@exussum12
Copy link
Collaborator

Can you give that change a go ? Seems to work for me locally (change the tests index.php to use the dev version)

@MeterSoft
Copy link
Author

yes, it work now https://jsfiddle.net/bohdansemenets/j4frtfw9/
but if i have list for 3 elements and validateion was failed only for 2 item, can i add error message only to this field, same as main model? all field should have different id

@exussum12
Copy link
Collaborator

The fix for that is in src/field.js

The fiddle doesnt include that in. It was ok when i was testing

@MeterSoft
Copy link
Author

I'm very confused as to what files I have to take and how to make it work?

@exussum12
Copy link
Collaborator

Yeah sorry about that. I can't compile the main file for the pull because it will create conflicts when merging. You may be able to include the SRC/field.js in with your fiddle. Not 100% sure

I'll upload how I was testing later today

@exussum12
Copy link
Collaborator

clone the codebase, and put this in the tests folder

http://pastebin.com/wDjVgXfv

Its your jsfiddle with the code change here

I cant add to the fiddle for some reason.

@exussum12
Copy link
Collaborator

http://pastebin.com/24L8CZsy backbone forms min

http://pastebin.com/uUvniwAC list min

Hope that helps

@MeterSoft
Copy link
Author

i put your code to test folder and it not working

http://i.imgur.com/30fCPn5.png

then i replaced /extra/list on
https://github.com/exussum12/backbone-forms/blob/6e48b0bb36761886bee7e990fec7b137f8e5f6f4/src/editors/extra/list.js
This fix is not located in master?

and now it began to work, but not quite right, instead of the actual error message We can see the same messages

http://i.imgur.com/NDP1zva.png

@powmedia
Copy link
Owner

@exussum12 Hi, I can't find a contact email for you, wanted to ask if you were interested in becoming a project admin as I don't have time to maintain this project any more.

@exussum12
Copy link
Collaborator

screenshot_2016-01-20_19-18-13

Thats how I see it. @powmedia possibly, Ill email you - are you still using the email from your commits ?

@powmedia
Copy link
Owner

@exussum12 yep
On 20 Jan 2016 19:19, "Scott Dutton" [email protected] wrote:

[image: screenshot_2016-01-20_19-18-13]
https://cloud.githubusercontent.com/assets/1102850/12460214/9bf664a8-bfaa-11e5-87f8-6aa63c55805e.png

Thats how I see it. @powmedia https://github.com/powmedia possibly, Ill
email you - are you still using the email from your commits ?


Reply to this email directly or view it on GitHub
#483 (comment)
.

@exussum12
Copy link
Collaborator

Replied to your email. Let me know if you received it

@MeterSoft
Copy link
Author

On yours screenshot you use ?

http://pastebin.com/24L8CZsy backbone forms min

http://pastebin.com/uUvniwAC list min

@exussum12
Copy link
Collaborator

I'll post the code I was using. What browser and is are you using ?

@MeterSoft
Copy link
Author

Firefox 43.0
I would like to receive a code that you use, because not quite clear what the code is actual
Also, whether the use of plug-in hidden fields such as id because when editing there is a need to send id neted models to server?

@exussum12
Copy link
Collaborator

jsfiddle seemed to work today, Added an example there

https://jsfiddle.net/zogkbnwe/2/

Can you confirm that works and then Ill work on the tests

@MeterSoft
Copy link
Author

yes, that works

@MeterSoft
Copy link
Author

what about support hidden id field, after submit form, it should ignore blank id fields, is it possible?

@exussum12
Copy link
Collaborator

This doesnt change the current behaviour for hidden forms ?

@MeterSoft
Copy link
Author

In documentation not have information about this.
i try added id field to schema and add hidden class to them, but when it is new form after commit it return empty id ("") so we should remove it from hash before send to server

it is very inconvenient, I think the form must take id and transmit the it if it is present

glenpike added a commit that referenced this issue Feb 11, 2016
quayle pushed a commit to quayle/backbone-forms that referenced this issue May 11, 2022
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

3 participants