Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2016
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    creating multiple input fields in rails

    Hi,

    I am trying to figure out how to put multiple input fields on a horizontal line. I don't know the correct syntax for the html inside the embedded ruby. I know what I have won't work, but I included that to show what I need. Can someone give me a hint so that I can figure the rest out on my own? thank you



    Code:
    <% (1..18).each do %>
          <%= input type="number" style="width: 8px" %>
    <% end %>

  2. #2
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,186
    Thanks
    4
    Thanked 462 Times in 450 Posts
    Well the first thing you shouldn't be doing is setting the width in the markup. That's your external stylesheet's job. Input in and of themselves are a special display type SIMILAR to inline-block, so they should all be inline if that is in fact a loop and outputting those inputs as such.

    I barely know ruby, but if that is indeed outputting 18 inputs in a row, they should fit on one line assuming the screen is wide enough for them to fit... regardless of their width. To try and set a fixed width on them (which should likely be done in EM, not pixels -- pixel layouts tell users with accessibility needs to go f*** themselves) I would either give each of them a class, or style them off a parent fieldset.

    You are outputting a full and complete form filled with fieldsets and labels, right? A bit disturbing to see a loop that's outputting only input without any <label> tags to say what those input ARE.

    In any case, you're question is about layout -- something that should have NOTHING to do with your HTML or server-side code. That's your stylesheet's job.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •