Ask A Question

Notifications

You’re not receiving notifications from this thread.

Adding an inline style to a Datetime_select field in simple_form

Lee Sheppard asked in Rails

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.

Reply

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

Reply

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.

Reply

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

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.