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

Persist school district data #17422

Merged
merged 2 commits into from Aug 31, 2017
Merged

Persist school district data #17422

merged 2 commits into from Aug 31, 2017

Conversation

mehalshah
Copy link
Contributor

@mehalshah mehalshah commented Aug 30, 2017

Form is now submittable and we will retain / validate school data

@mehalshah mehalshah requested a review from Hamms August 30, 2017 20:43
@@ -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());
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash = sanitize_form_data_hash

unless hash[:school_type].presence && hash[:school_state].presence
add_key_error('Missing school district data')
Copy link
Contributor

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.

@mehalshah mehalshah merged commit 560b8e7 into staging Aug 31, 2017
@mehalshah mehalshah deleted the persist_school_district_data branch August 31, 2017 23:13
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

Successfully merging this pull request may close these issues.

None yet

2 participants