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
Persist school district data #17422
Persist school district data #17422
Conversation
@@ -7,6 +7,31 @@ export default class RegionalPartnerContact extends FormController { | |||
/** | |||
* @override | |||
*/ | |||
serializeFormData() { | |||
const dataWithDistrict = {}; | |||
dataWithDistrict['form_data'] = Object.assign({}, super.serializeFormData()['form_data'], this.getDistrictData()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit; this means that if serializeFormData
were to return any ancillary data not in 'form_data'
, it would here be discarded. Something like
const formData = super.serializeFormData();
Object.assign(formData['form_data'], this.getDistrictData());
return formData
Would be nicer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
schoolDistrictData['school-other'] = document.getElementById('school-other').checked; | ||
schoolDistrictData['school-district-name'] = document.getElementById('school-district-name').value; | ||
schoolDistrictData['school-name'] = document.getElementById('school-name').value; | ||
schoolDistrictData['school-zipcode'] = document.getElementById('school-zipcode').value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are these elements getting added to the page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are elements in the school_info partial
0090b71
to
2b1c3cd
Compare
hash = sanitize_form_data_hash | ||
|
||
unless hash[:school_type].presence && hash[:school_state].presence | ||
add_key_error('Missing school district data') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_key_error
actually expects the hash key as an argument, so add_key_error(:school_type)
would be more appropriate (and if you wanted to do that, it would be easier to just add these keys to required_fields
).
That being said, the key error is used by the FormController to highlight its own errors, so using it for something that's not controlled by react will mean no meaningful errors get displayed to the user no matter what value you give it.
If you want meaningful feedback for school district errors, you'll have to flash
or something.
5080d0a
to
9625a8d
Compare
Form is now submittable and we will retain / validate school data