Skip to content

Instantly share code, notes, and snippets.

@rociopaez
Last active August 29, 2015 14:06
Show Gist options
  • Save rociopaez/062f3aeb6a89f3d78bf8 to your computer and use it in GitHub Desktop.
Save rociopaez/062f3aeb6a89f3d78bf8 to your computer and use it in GitHub Desktop.
<h2>Migraine tracker - Inputs</h2>
<form action="/inputs" method="POST">
<fieldset>
<label for="date">Date</label>
<select name="input[date_month]">
% 1.upto(12).each do |i|
<option{{ ' selected="selected"' if Time.now.month == i }}>{{ i }}</option>
% end
</select>
<select name="input[date_day]">
% 1.upto(31).each do |i|
<option{{ ' selected="selected"' if Time.now.day == i }}>{{ i }}</option>
% end
</select>
<select name="input[date_year]">
% this_year = Time.now.year
% start_year = this_year - 2
% start_year.upto(this_year).each do |i|
<option{{ ' selected="selected"' if Time.now.year == i }}>{{ i }}</option>
% end
</select>
<label for="types">Types</label>
<select name="input[type_id]">
% params[:types].group_by { |type| type.category }.each do |category, types|
<optgroup label="{{ category }}">
% types.each do |type|
<option value="{{ type.id }}">{{ type.name }}</option>
% end
</optgroup>
% end
</select>
</fieldset>
<input type="submit" value="send">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment