maxbeizer / applicable

A rails app to enhance the NSS application process
applicable.herokuapp.com
0 stars 2 forks source link

Required Fields #4

Open maxbeizer opened 11 years ago

maxbeizer commented 11 years ago

As of right now, none of the fields are required, though most fields are required in the current NSS application. I didn't do this straight off because I didn't want to have to fill in all the fields during early stage browser testing. Still, it probably should get done at some point.

It should be as easy as adding required to the simple_form elements in student/_form.html.erb

hassanshamim commented 11 years ago

"It should be as easy as..." - Famous last words.

So it isn't as easy as adding the required fields to the form elements. Technically, it's easier. From the docs:

Required fields are marked with an * prepended to their labels.

By default all inputs are required. When the form object has presence validations attached to its fields, SimpleForm tells required and optional fields apart. For performance reasons, this detection is skipped on validations that make use of conditional options, such as :if and :unless.

from the docs

Except for some reason, fields being required aren't the default. This is simple enough to fix, as you can set default attributes for fields when you invoke simple_form_for with :defaults => { required: true }. However, I've tested this and all it does is add a * to the fields, but doesn't validate the presence of contents in any of them. You can update or complete your application without any errors popping up.

Now, if you add validations for the attributes in the model, errors appear for both the update and complete actions in the Students controller, which is sub-optimal as I presume we want prospective students to be able to fill out the application in chunks before submitting it as complete.

As I see it, we can invoke specific validations when routed to the complete action, which is hacky and not very rails-y. We can create a new model/controller for completed/archived applications, making it more RESTful. Or we can figure out what's going wrong with the simple_form gem and get it to work properly (assuming it can do such and it's not in conflict with another gem.).

Anyway, it's your app, thought you'd be more familiar and have some input. I think the simplest solution would be best, so I can just create the changes in a branch and you can rebase it at once all the other issues are addressed.

</ wall_of_text >