Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Adding an inline style to a Datetime_select field in simple_form

Rails • Asked by Lee Sheppard

How do I add an inline style to a Datetime_select field in simple_form?
What I would like to have worked (this is in Slim):

= f.datetime_select :published_at, style="width:auto;"

but this isn't the case. It doesn't add the style. The app admin is managed through a gem and I don't want to modify the styling in that gem. So I'm trying to override the widths to correct their display by doing inline styling.

from the documentation :
datetime_select(object_name, method, options = {}, html_options = {})
in your case try this :
= f.datetime_select :published_at,{} ,{style="width:auto;"}

It seems that you can only apply classes and not inline styling to simple_form. Which is a shame if you need to have a hack in place.

I think that you can do it from the html_options = {}

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,152+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.