I’ve got a form with a date and I want prompt the user if they submit the form outside of a range, but still give them the opportunity to submit outside the range.
For instance (pseudocode)
if date < start_date and current_user.admin?
answer = ask 'are you sure you want to submit below the date range?'
elsif date > end_date
answer = ask 'are you sure you want to submit over the date range?'
else
answer = 'yes'
end
if answer == 'yes'
submit
else
return to original form
end
I was thinking one solution would be a multi-form wizard type of implementation but is there an easier way?
For instance, first I would show the original form with the date field. Then when the user hits the ‘submit’ button check with the server if we have to ask the user to confirm their out of range date, if so show a partial and wait for them to hit the ‘confirm’ or ‘yes’ button.
To me it sounds like you should have an intermediary action in your controller which you submit the form to. This intermediary action validates the form parameters, and renders the partial or just submits the form accordingly. The partial’s submit button would contain a link to the final action which deals with submission.