开发者

List Entry and Display Best Practice

开发者 https://www.devze.com 2022-12-19 07:16 出处:网络
I have an application where when users sign up they get to choose the day of the week they would like to describe. Each User has a mondaysub, tuesdaysub, etc (all strings) to store whe开发者_运维技巧t

I have an application where when users sign up they get to choose the day of the week they would like to describe. Each User has a mondaysub, tuesdaysub, etc (all strings) to store whe开发者_运维技巧ther or not they are to receive an email on those days. For some other reasons, I need to keep it so that f or t mark in each column to designate subscribed to each day or not.

Currently I have:

<% form_for @user do |f| %>

<h3>Please select the days you would like to recieve a trailer!</h3>
 <%= f.check_box :mondaysub, {}, "t", "f" %> <label>Monday</label>
 <%= f.check_box :tuesdaysub, {}, "t", "f" %> <label>Tuesday</label>
 <%= f.check_box :wednesdaysub, {}, "t", "f" %> <label>Wednesday</label>
 <%= f.check_box :thursdaysub, {}, "t", "f" %> <label>Thursday</label>
 <%= f.check_box :fridaysub, {}, "t", "f" %> <label>Friday</label><br>
 <%= f.check_box :saturdaysub, {}, "t", "f" %> <label>Saturday</label>
 <%= f.check_box :sundaysub, {}, "t", "f" %> <label>Sunday</label><br>
  <p><%= f.submit "Subscribe Me!" %></p>
<% end %>

My question is... is there a better way to allow users to select which days of the week they want to receive mail on (more user friendly then checking individual boxes) but I still get the data stored how I need it to. Also, I would like the users to see what they are subscribed to when they come back to edit.

Thanks!


To clean up your form you could do:

<% %w{monday tuesday wednesday thursday friday saturday sunday}.each do |day| %>
  <%= f.checkbox "#{day}sub".to_sym, {}, "t", "f"%>
  <label><%= day.camelcase %></label>
<% end %>

As for how to present this in UI:

I would recommend keeping the idea of checkboxes since they toggle on/off. You can style them however you want, you could even use something like jQuery to (on page load) hide the checkboxes and display a more friendly UI that simply checks/unchecks the checkboxes in the background.

Also, you should think about if there are certain defaults that meet most of your users' needs. For example, if most users will want mon-fri, you could have those selected on page load, leaving only the user's small customizations necessary to perform.


How about doing:

Please select a day you would like to receive trailers: |DROPDOWN| |ADD BUTTON|


First off you should do this :

<%= f.check_box :something %>    
<%= f.label :something %>

This will associate the label and the checkbox

Concerning the UI you should keep the checkboxes but have them layed out nicely so it doesn't feel like a large form.

To do so, padding is your friend. Also add some hover states and an image or too and you should be good to go :)

0

精彩评论

暂无评论...
验证码 换一张
取 消