No commit activity in last 3 years
No release in over 3 years
Allows to use block labels as wrappers for inputs, without loosing i18n stuff.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 3.0
 Project Readme

Rails Block Labels

Rails sucks at forms styling/formatting point. One nice idea to keep forms slim and easy to style is to place inputs inside the label tag. This is hack which give you standard label behavior (eg. i18n supoprt) with block wrapping.

Usage

Add to your gemfile:

gem 'rails-block-labels'

And enjoy block labels in your views, example:

<%= form_for @post do |f| %>
  <%= f.label :title do %>
    <% f.text_field :title %>
  <% end %>
  <%= f.label :content do %>
    <% f.text_area :content %>
  <% end %>
  
  *ship*
<% end %>

Example above produces:

<form ...>
  <label for="post_title">
    Title
	<input name="post[title]" ...>
  </label>
  ...
</form>

IMPORTANT! Form fields within label block can't be printed out with <%=. You have to use <% instead. Don't ask me why, no fucking idea o_O". It's a kind of Magic... ♪♬

License

THE BEER-WARE LICENSE chris@nu7hat.ch wrote this stuff. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return Chris Kowalik.