can anybody point me at a solution how to persist data from form, when this form is sent and something failed, validation for example?
I have DataObject bounded to Page with one to many relationship like in this doc: http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management.
If one of this fields: http://doc.silverstripe.org//src/sapphire_2.4/docs/en/tutorials/_images/gsoc-student-creation.jpg would be required (for example First Name) and i try to add new student without filling this required field, whole form will be submited, an error message will show up and all data from form are lost. How can I prevent this behaviour?
But I don't know how can I access form object in DataObject::getCMSFields method. It is possible anyway?
There is only FormField::setValue method (or constructor third parameter) on field object, but this is not working, neither FieldSet::setValues. I think, this is not working, because values are overwritten in Form::loadDataFrom and thats called from CMSMain::getEditForm.
But I don't know how can I access form object in DataObject::getCMSFields method. It is possible anyway? I think you should be able to access the session at any point, but I don't know if there will be anything in it... that specfication is new to me.
Personally I have never had this issue within the CMS, using plain model admin by creating my own validator and I don't need to worry about the session stuff....
I think you should be able to access the session at any point, but I don't know if there will be anything in it... that specfication is new to me. Yes, yes, I can access session data, thats not a problem (and thanks for info about this).
Validation works too, but if form validation failed (for example, i don't fill required field), every data I filled in form are lost and I have to fill whole form again and thats annoying - especially for my client :))