Formatting date_select field

I have a date_select field created with the following code:

<div class="form-group">
     <%= date_select f, :date_of_birth, builder: fn b -> %>
        Day and Month of Birth: <%= b.(:day, []) %> / <%= b.(:month, []) %> / <%= b.(:year, [options: 1950..1998]) %>
      <% end %>
     <%= error_tag f, :date_of_birth %>
</div>

Now the individual day, month and year fields are vertically stacked on top of each other and each takes the whole row. What I need is to have them horizontally next with each other with the forward slash seperator between them. I’m using Bootstrap for the css side of things.

Thanks.

1 Like

Just set the css in your css file for those elements to be display: inline-block; or something like that. :slight_smile:

1 Like

How do I get the current day on this div?

1 Like

The div does not hold information, rather the select’s that the datetime_select creates do, query them, they have an id too for easy querying as you can see at those docs, based on the name you give it. :slight_smile:

1 Like

I was looking for something like that.

<div class="form-group">
     <%= label f, :data, class: "control-label" %>
     <%= date_select f, :data, builder: fn b -> %>
        <%= b.(:day, [date.day]) %> / <%= b.(:month, [date.month]) %> / <%= b.(:year, [options: 2017..2020]) %>
        <% end %>
     <%= error_tag f, :data %>
</div>

In “controller” >

def create <
“Date = Date.utc_today ()”

But I’m not getting

1 Like