All threads / Simple Form - Make label appear after input

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Simple Form - Make label appear after input

Michael Victor asked in Gems / Libraries

I have a simple form tag as given below:

= f.input :email, required: true, input_html: {class: 'md-input'}, wrapper_html: {class: 'md-form-group float-lable'}
and it generates the below HTML

* Email

How can I adjust the Simple Form tag such that the label element appears after the input element?

I've tried inline_label but that didn't seem to work as it was not intended for this purpose anyways

You might just need to add a float: right to the label with some CSS which may do the trick.

The other alternative I can think of would be to just mix and match your simple form and normal form html tags. I usually do this when I want most of a form to be simple form styled but one field needs to be custom. It's usually easiest to just write up the form html like I would with a regular form_for and simple_form will let you mix and match like that. That could be another approach that would do the trick.

I think that makes sense and a good approach - to mix and match! It worked for me in this case!

Thanks!

Join the discussion

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.