backbone-forms
backbone-forms copied to clipboard
List validation
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
Use master if possible master has support for it, it was added here https://github.com/powmedia/backbone-forms/issues/414
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
Can you give an example ? Im pretty sure i fixed that issue too
https://jsfiddle.net/bohdansemenets/zogkbnwe/
Can you give that change a go ? Seems to work for me locally (change the tests index.php to use the dev version)
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
The fix for that is in src/field.js
The fiddle doesnt include that in. It was ok when i was testing
I'm very confused as to what files I have to take and how to make it work?
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
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.
http://pastebin.com/24L8CZsy backbone forms min
http://pastebin.com/uUvniwAC list min
Hope that helps
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
@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.

Thats how I see it. @powmedia possibly, Ill email you - are you still using the email from your commits ?
@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 https://github.com/powmedia/backbone-forms/issues/483#issuecomment-173330303 .
Replied to your email. Let me know if you received it
On yours screenshot you use ?
http://pastebin.com/24L8CZsy backbone forms min
http://pastebin.com/uUvniwAC list min
I'll post the code I was using. What browser and is are you using ?
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?
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
yes, that works
what about support hidden id field, after submit form, it should ignore blank id fields, is it possible?
This doesnt change the current behaviour for hidden forms ?
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