[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7731":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":9,"rankLanguage":9,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":21,"topics":22,"createdAt":9,"pushedAt":9,"updatedAt":23,"readmeContent":24,"aiSummary":25,"trendingCount":15,"starSnapshotCount":15,"syncStatus":26,"lastSyncTime":27,"discoverSource":28},7731,"formtastic","formtastic\u002Fformtastic","A Rails form builder plugin with semantically rich and accessible markup.","",null,"Ruby",5215,625,67,3,0,11,39.39,"MIT License",false,"master",true,[],"2026-06-12 02:01:43","# Formtastic\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic\u002Fworkflows\u002Ftest\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic\u002Factions)\n[![Inline docs](https:\u002F\u002Finch-ci.org\u002Fgithub\u002Fjustinfrench\u002Fformtastic.svg?branch=master)](https:\u002F\u002Finch-ci.org\u002Fgithub\u002Fjustinfrench\u002Fformtastic)\n[![Code Climate](https:\u002F\u002Fqlty.sh\u002Fgh\u002Fformtastic\u002Fprojects\u002Fformtastic\u002Fmaintainability.svg)](https:\u002F\u002Fqlty.sh\u002Fgh\u002Fformtastic\u002Fprojects\u002Fformtastic)\n[![Gem Version](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Fformtastic.svg)](https:\u002F\u002Fbadge.fury.io\u002Frb\u002Fformtastic)\n\nFormtastic is a Rails FormBuilder DSL (with some other goodies) to make it far easier to create beautiful, semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications.\n\n## Documentation & Support\n\n* [Documentation is available on rubydoc.info](https:\u002F\u002Frubydoc.info\u002Fgithub\u002Fformtastic\u002Fformtastic)\n* [We track issues & bugs on GitHub](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic\u002Fissues)\n* [We have a wiki on GitHub](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic\u002Fwiki)\n* [StackOverflow can help](https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fformtastic)\n\n## Compatibility\n\n* Formtastic 6.x requires Rails 7.2 and Ruby 3.1 minimum, inline with Rails minimum supported versions\n* Formtastic 5.x requires Rails 6.0 and Ruby 2.6 minimum\n* Formtastic, much like Rails, is very ActiveRecord-centric. Many are successfully using other ActiveModel-like ORMs and objects (DataMapper, MongoMapper, Mongoid, Authlogic, Devise...) but we're not guaranteeing full compatibility at this stage. Patches are welcome!\n\n## The Story\n\nOne day, I finally had enough, so I opened up my text editor, and wrote a DSL for how I'd like to author forms:\n\n```erb\n  \u003C%= semantic_form_for @article do |f| %>\n\n    \u003C%= f.inputs :name => \"Basic\" do %>\n      \u003C%= f.input :title %>\n      \u003C%= f.input :body %>\n      \u003C%= f.input :section %>\n      \u003C%= f.input :publication_state, :as => :radio %>\n      \u003C%= f.input :category %>\n      \u003C%= f.input :allow_comments, :label => \"Allow commenting on this article\" %>\n    \u003C% end %>\n\n    \u003C%= f.inputs :name => \"Advanced\" do %>\n      \u003C%= f.input :keywords, :required => false, :hint => \"Example: ruby, rails, forms\" %>\n      \u003C%= f.input :extract, :required => false %>\n      \u003C%= f.input :description, :required => false %>\n      \u003C%= f.input :url_title, :required => false %>\n    \u003C% end %>\n\n    \u003C%= f.inputs :name => \"Author\", :for => :author do |author_form| %>\n      \u003C%= author_form.input :first_name %>\n      \u003C%= author_form.input :last_name %>\n    \u003C% end %>\n\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit, :as => :button %>\n      \u003C%= f.action :cancel, :as => :link %>\n    \u003C% end %>\n\n  \u003C% end %>\n```\n\nI also wrote the accompanying HTML output I expected, favoring something very similar to the fieldsets, lists and other semantic elements Aaron Gustafson presented in [Learning to Love Forms](https:\u002F\u002Fwww.slideshare.net\u002Fslideshow\u002Flearning-to-love-forms-webvisions-07\u002F45589), hacking together enough Ruby to prove it could be done.\n\n\n## It's awesome because...\n\n* It can handle `belongs_to` associations (like Post belongs_to :author), rendering a select or set of radio inputs with choices from the parent model.\n* It can handle `has_many` and `has_and_belongs_to_many` associations (like: Post has_many :tags), rendering a multi-select with choices from the child models.\n* It's Rails 3\u002F4 compatible (including nested forms).\n* It has internationalization (I18n)!\n* It's _really_ quick to get started with a basic form in place (4 lines), then go back to add in more detail if you need it.\n* There's heaps of elements, id and class attributes for you to hook in your CSS and JS.\n* It handles real world stuff like inline hints, inline error messages & help text.\n* It doesn't hijack or change any of the standard Rails form inputs, so you can still use them as expected (even mix and match).\n* It's got absolutely awesome spec coverage.\n* There's a bunch of people using and working on it (it's not just one developer building half a solution).\n* It has growing HTML5 support (new inputs like email\u002Fphone\u002Fsearch, new attributes like required\u002Fmin\u002Fmax\u002Fstep\u002Fplaceholder)\n\n\n## Opinions\n\n* It should be easier to do things the right way than the wrong way.\n* Sometimes _more mark-up_ is better.\n* Elements and attribute hooks are _gold_ for stylesheet authors.\n* Make the common things we do easy, yet ensure uncommon things are still possible.\n\n\n## Installation\n\nSimply add Formtastic to your Gemfile and bundle it up:\n\n```ruby\n  gem 'formtastic', '~> 5.0'\n```\n\nRun the installation generator:\n\n```shell\n$ rails generate formtastic:install\n```\n\n\n## Stylesheets\n\nAn optional proof-of-concept stylesheet can be generated and installed into your app:\n\n```shell\n$ rails generate formtastic:stylesheet\n```\n\n\n## Usage\n\nForms are really boring to code... you want to get onto the good stuff as fast as possible.\n\nThis renders a set of inputs (one for _most_ columns in the database table, and one for each ActiveRecord `belongs_to`-association), followed by default action buttons (an input submit button):\n\n```erb\n  \u003C%= semantic_form_for @user do |f| %>\n    \u003C%= f.inputs %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nThis is a great way to get something up fast, but like scaffolding, it's *not recommended for production*. Don't be so lazy!\n\nTo specify the order of the fields, skip some of the fields or even add in fields that Formtastic couldn't infer. You can pass in a list of field names to `inputs` and list of action names to `actions`:\n\n```erb\n  \u003C%= semantic_form_for @user do |f| %>\n    \u003C%= f.inputs :title, :body, :section, :categories, :created_at %>\n    \u003C%= f.actions :submit, :cancel %>\n  \u003C% end %>\n```\n\nYou probably want control over the input type Formtastic uses for each field. You can expand the `inputs` and `actions` to block helper format and use the `:as` option to specify an exact input type:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title %>\n      \u003C%= f.input :body %>\n      \u003C%= f.input :section, :as => :radio %>\n      \u003C%= f.input :categories %>\n      \u003C%= f.input :created_at, :as => :string %>\n    \u003C% end %>\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit, :as => :button %>\n      \u003C%= f.action :cancel, :as => :link %>\n    \u003C% end %>\n  \u003C% end %>\n```\n\nIf you want to customize the label text, or render some hint text below the field, specify which fields are required\u002Foptional, or break the form into two fieldsets, the DSL is pretty comprehensive:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs \"Basic\", :id => \"basic\" do %>\n      \u003C%= f.input :title %>\n      \u003C%= f.input :body %>\n    \u003C% end %>\n    \u003C%= f.inputs :name => \"Advanced Options\", :id => \"advanced\" do %>\n      \u003C%= f.input :slug, :label => \"URL Title\", :hint => \"Created automatically if left blank\", :required => false %>\n      \u003C%= f.input :section, :as => :radio %>\n      \u003C%= f.input :user, :label => \"Author\" %>\n      \u003C%= f.input :categories, :required => false %>\n      \u003C%= f.input :created_at, :as => :string, :label => \"Publication Date\", :required => false %>\n    \u003C% end %>\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit %>\n    \u003C% end %>\n  \u003C% end %>\n```\n\nYou can create forms for nested resources:\n\n```erb\n\t\u003C%= semantic_form_for [@author, @post] do |f| %>\n```\n\nNested forms are also supported (don't forget your models need to be setup correctly with `accepts_nested_attributes_for`). You can do it in the Rails way:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs :title, :body, :created_at %>\n    \u003C%= f.semantic_fields_for :author do |author| %>\n      \u003C%= author.inputs :first_name, :last_name, :name => \"Author\" %>\n    \u003C% end %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nOr the Formtastic way with the `:for` option:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs :title, :body, :created_at %>\n    \u003C%= f.inputs :first_name, :last_name, :for => :author, :name => \"Author\" %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nWhen working in has many association, you can even supply `\"%i\"` in your fieldset name; they will be properly interpolated with the child index. For example:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs %>\n    \u003C%= f.inputs :name => 'Category #%i', :for => :categories %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nAlternatively, the current index can be accessed via the `inputs` block's arguments for use anywhere:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs :for => :categories do |category, i| %>\n      ...\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nIf you have more than one form on the same page, it may lead to HTML invalidation because of the way HTML element id attributes are assigned. You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generate HTML id. For example:\n\n```erb\n  \u003C%= semantic_form_for(@post, :namespace => 'cat_form') do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title %>        # id=\"cat_form_post_title\"\n      \u003C%= f.input :body %>         # id=\"cat_form_post_body\"\n      \u003C%= f.input :created_at %>   # id=\"cat_form_post_created_at\"\n    \u003C% end %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nCustomize HTML attributes for any input using the `:input_html` option. Typically this is used to disable the input, change the size of a text field, change the rows in a textarea, or even to add a special class to an input to attach special behavior like [autogrow](https:\u002F\u002Fplugins.jquery.com\u002Fproject\u002Fautogrowtextarea) textareas:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title,      :input_html => { :size => 10 } %>\n      \u003C%= f.input :body,       :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 10  } %>\n      \u003C%= f.input :created_at, :input_html => { :disabled => true } %>\n      \u003C%= f.input :updated_at, :input_html => { :readonly => true } %>\n    \u003C% end %>\n    \u003C%= f.actions %>\n  \u003C% end %>\n```\n\nThe same can be done for actions with the `:button_html` option:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    ...\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit, :button_html => { :class => \"primary\", :disable_with => 'Wait...' } %>\n    \u003C% end %>\n  \u003C% end %>\n```\n\nCustomize the HTML attributes for the `\u003Cli>` wrapper around every input with the `:wrapper_html` option hash. There's one special key in the hash: (`:class`), which will actually _append_ your string of classes to the existing classes provided by Formtastic (like `\"required string error\"`).\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title, :wrapper_html => { :class => \"important\" } %>\n      \u003C%= f.input :body %>\n      \u003C%= f.input :description, :wrapper_html => { :style => \"display:none;\" } %>\n    \u003C% end %>\n    ...\n  \u003C% end %>\n```\n\nMany inputs provide a collection of options to choose from (like `:select`, `:radio`, `:check_boxes`, `:boolean`). In many cases, Formtastic can find choices through the model associations, but if you want to use your own set of choices, the `:collection` option is what you want.  You can pass in an Array of objects, an array of Strings, a Hash... Throw almost anything at it! Examples:\n\n```ruby\n  f.input :authors, :as => :check_boxes, :collection => User.order(\"last_name ASC\").all\n  f.input :authors, :as => :check_boxes, :collection => current_user.company.users.active\n  f.input :authors, :as => :check_boxes, :collection => [@justin, @kate]\n  f.input :authors, :as => :check_boxes, :collection => [\"Justin\", \"Kate\", \"Amelia\", \"Gus\", \"Meg\"]\n  f.input :author,  :as => :select,      :collection => Author.all\n  f.input :author,  :as => :select,      :collection => Author.pluck(:first_name, :id)\n  f.input :author,  :as => :select,      :collection => Author.pluck(Arel.sql(\"CONCAT(`first_name`, ' ', `last_name`)\"), :id)\n  f.input :author,  :as => :select,      :collection => Author.your_custom_scope_or_class_method\n  f.input :author,  :as => :select,      :collection => { @justin.name => @justin.id, @kate.name => @kate.id }\n  f.input :author,  :as => :select,      :collection => [\"Justin\", \"Kate\", \"Amelia\", \"Gus\", \"Meg\"]\n  f.input :author,  :as => :radio,       :collection => User.all\n  f.input :author,  :as => :radio,       :collection => [@justin, @kate]\n  f.input :author,  :as => :radio,       :collection => { @justin.name => @justin.id, @kate.name => @kate.id }\n  f.input :author,  :as => :radio,       :collection => [\"Justin\", \"Kate\", \"Amelia\", \"Gus\", \"Meg\"]\n  f.input :admin,   :as => :radio,       :collection => [\"Yes!\", \"No\"]\n  f.input :book_id, :as => :select,      :collection => Hash[Book.all.map{|b| [b.name,b.id]}]\n  f.input :fav_book,:as => :datalist   , :collection => Book.pluck(:name)\n```\n\n\n## The Available Inputs\n\nThe Formtastic input types:\n\n* `:select` - a select menu. Default for ActiveRecord associations: `belongs_to`, `has_many`, and `has_and_belongs_to_many`.\n* `:check_boxes` - a set of check_box inputs. Alternative to `:select` for ActiveRecord-associations: `has_many`, and has_and_belongs_to_many`.\n* `:radio` - a set of radio inputs. Alternative to `:select` for ActiveRecord-associations: `belongs_to`.\n* `:time_zone` - a select input. Default for column types: `:string` with name matching `\"time_zone\"`.\n* `:password` - a password input. Default for column types: `:string` with name matching `\"password\"`.\n* `:text` - a textarea. Default for column types: `:text`.\n* `:date_select` - a date select. Default for column types: `:date`.\n* `:datetime_select` - a date and time select. Default for column types: `:datetime` and `:timestamp`.\n* `:time_select` - a time select. Default for column types: `:time`.\n* `:boolean` - a checkbox. Default for column types: `:boolean`.\n* `:string` - a text field. Default for column types: `:string`.\n* `:number` - a text field (just like string). Default for  column types: `:integer`, `:float`, and `:decimal`.\n* `:file` - a file field. Default for file-attachment attributes matching: [paperclip](https:\u002F\u002Fgithub.com\u002Fthoughtbot\u002Fpaperclip) or [attachment_fu](https:\u002F\u002Fgithub.com\u002Ftechnoweenie\u002Fattachment_fu).\n* `:country` - a select menu of country names. Default for column types: `:string` with name `\"country\"` - requires a *country_select* plugin to be installed.\n* `:email` - a text field (just like string). Default for columns with name matching `\"email\"`. New in HTML5. Works on some mobile browsers already.\n* `:url` - a text field (just like string). Default for columns with name matching `\"url\"`. New in HTML5. Works on some mobile browsers already.\n* `:phone` - a text field (just like string). Default for columns with name matching `\"phone\"` or `\"fax\"`. New in HTML5.\n* `:search` - a text field (just like string). Default for columns with name matching `\"search\"`. New in HTML5. Works on Safari.\n* `:hidden` - a hidden field. Creates a hidden field (added for compatibility).\n* `:range` - a slider field.\n* `:datalist` - a text field with a accompanying [datalist tag](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTML\u002FReference\u002FElements\u002Fdatalist) which provides options for autocompletion\n\nThe comments in the code are pretty good for each of these (what it does, what the output is, what the options are, etc.) so go check it out.\n\n\n## Delegation for label lookups\n\nFormtastic decides which label to use in the following order:\n\n```\n  1. :label             # :label => \"Choose Title\"\n  2. Formtastic i18n    # if either :label => true || i18n_lookups_by_default = true (see Internationalization)\n  3. Activerecord i18n  # if localization file found for the given attribute\n  4. label_str_method   # if nothing provided this defaults to :humanize but can be set to a custom method\n```\n\n## Internationalization (I18n)\n\n### Basic Localization\n\nFormtastic has some neat I18n-features. ActiveRecord object names and attributes are, by default, taken from calling `@object.human_name` and `@object.human_attribute_name(attr)` respectively. There are a few words specific to Formtastic that can be translated. See `lib\u002Flocale\u002Fen.yml` for more information.\n\nBasic localization (labels only, with ActiveRecord):\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title %>        # => :label => I18n.t('activerecord.attributes.user.title')    or 'Title'\n      \u003C%= f.input :body %>         # => :label => I18n.t('activerecord.attributes.user.body')     or 'Body'\n      \u003C%= f.input :section %>      # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'\n    \u003C% end %>\n  \u003C% end %>\n```\n\n*Note:* This is perfectly fine if you just want your labels\u002Fattributes and\u002For models to be translated using *ActiveRecord I18n attribute translations*, and you don't use input hints and legends. But what if you do? And what if you don't want same labels in all forms?\n\n### Enhanced Localization (Formtastic I18n API)\n\nFormtastic supports localized *labels*, *hints*, *legends*, *actions* using the I18n API for more advanced usage. Your forms can now be DRYer and more flexible than ever, and still fully localized. This is how:\n\n*1. Enable I18n lookups by default (`config\u002Finitializers\u002Fformtastic.rb`):*\n\n```ruby\n  Formtastic::FormBuilder.i18n_lookups_by_default = true\n```\n\n*2. Add some label-translations\u002Fvariants (`config\u002Flocales\u002Fen.yml`):*\n\n```yml\n  en:\n    formtastic:\n      titles:\n        post_details: \"Post details\"\n      labels:\n        post:\n          title: \"Your Title\"\n          body: \"Write something...\"\n          edit:\n            title: \"Edit title\"\n      hints:\n        post:\n          title: \"Choose a good title for your post.\"\n          body: \"Write something inspiring here.\"\n      placeholders:\n        post:\n          title: \"Title your post\"\n          slug: \"Leave blank for an automatically generated slug\"\n        user:\n          email: \"you@yours.com\"\n      actions:\n        create: \"Create my %{model}\"\n        update: \"Save changes\"\n        reset: \"Reset form\"\n        cancel: \"Cancel and go back\"\n        dummie: \"Launch!\"\n```\n\n*3. ...and now you'll get:*\n\n```erb\n  \u003C%= semantic_form_for Post.new do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title %>      # => :label => \"Choose a title...\", :hint => \"Choose a good title for your post.\"\n      \u003C%= f.input :body %>       # => :label => \"Write something...\", :hint => \"Write something inspiring here.\"\n      \u003C%= f.input :section %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'\n    \u003C% end %>\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit %>   # => \"Create my %{model}\"\n    \u003C% end %>\n  \u003C% end %>\n```\n\n*4. Localized titles (a.k.a. legends):*\n\n_Note: Slightly different because Formtastic can't guess how you group fields in a form. Legend text can be set with first (as in the sample below) specified value, or :name\u002F:title options - depending on what flavor is preferred._\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs :post_details do %>   # => :title => \"Post details\"\n      # ...\n    \u003C% end %>\n    # ...\n\u003C% end %>\n```\n\n*5. Override I18n settings:*\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title %>      # => :label => \"Choose a title...\", :hint => \"Choose a good title for your post.\"\n      \u003C%= f.input :body, :hint => false %>                 # => :label => \"Write something...\"\n      \u003C%= f.input :section, :label => 'Some section' %>    # => :label => 'Some section'\n    \u003C% end %>\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit, :label => :dummie %>         # => \"Launch!\"\n    \u003C% end %>\n  \u003C% end %>\n```\n\nIf I18n-lookups is disabled, i.e.:\n\n```ruby\n  Formtastic::FormBuilder.i18n_lookups_by_default = false\n```\n\n...then you can enable I18n within the forms instead:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.inputs do %>\n      \u003C%= f.input :title, :label => true %>      # => :label => \"Choose a title...\"\n      \u003C%= f.input :body, :label => true %>       # => :label => \"Write something...\"\n      \u003C%= f.input :section, :label => true %>    # => :label => I18n.t('activerecord.attributes.user.section')  or 'Section'\n    \u003C% end %>\n    \u003C%= f.actions do %>\n      \u003C%= f.action :submit, :label => true %>    # => \"Update %{model}\" (if we are in edit that is...)\n    \u003C% end %>\n  \u003C% end %>\n```\n\n*6. Advanced I18n lookups*\n\nFor more flexible forms; Formtastic finds translations using a bottom-up approach taking the following variables in account:\n\n* `MODEL`, e.g. \"post\"\n* `ACTION`, e.g. \"edit\"\n* `KEY\u002FATTRIBUTE`, e.g. \"title\", :my_custom_key, ...\n\n...in the following order:\n\n1. `formtastic.{titles,labels,hints,actions}.MODEL.ACTION.ATTRIBUTE` - by model and action\n2. `formtastic.{titles,labels,hints,actions}.MODEL.ATTRIBUTE` - by model\n3. `formtastic.{titles,labels,hints,actions}.ATTRIBUTE` - global default\n\n...which means that you can define translations like this:\n\n```yml\n  en:\n    formtastic:\n      labels:\n        title: \"Title\"  # Default global value\n        article:\n          body: \"Article content\"\n        post:\n          new:\n            title: \"Choose a title...\"\n            body: \"Write something...\"\n          edit:\n            title: \"Edit title\"\n            body: \"Edit body\"\n```\n\nValues for `labels`\u002F`hints`\u002F`actions` are can take values: `String` (explicit value), `Symbol` (i18n-lookup-key relative to the current \"type\", e.g. actions:), `true` (force I18n lookup), `false` (force no I18n lookup). Titles (legends) can only take: `String` and `Symbol` - true\u002Ffalse have no meaning.\n\n*7. Basic Translations*\nIf you want some basic translations, take a look on the [formtastic_i18n gem](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic_i18n).\n\n## Semantic errors\n\nYou can show errors on base (by default) and any other attribute just by passing its name to the semantic_errors method:\n\n```erb\n  \u003C%= semantic_form_for @post do |f| %>\n    \u003C%= f.semantic_errors :state %>\n  \u003C% end %>\n```\n\n\n## Modified & Custom Inputs\n\nYou can modify existing inputs, subclass them, or create your own from scratch. Here's the basic process:\n\n* Run the input generator and provide your custom input name. For example, `rails generate formtastic:input hat_size`. This creates the file `app\u002Finputs\u002Fhat_size_input.rb`. You can also provide namespace to input name like `rails generate formtastic:input foo\u002Fcustom` or `rails generate formtastic:input Foo::Custom`, this will create the file `app\u002Finputs\u002Ffoo\u002Fcustom_input.rb` in both cases.\n* To use that input, leave off the word \"input\" in your `as` statement. For example, `f.input(:size, :as => :hat_size)`\n\nSpecific examples follow.\n\n### Changing Existing Input Behavior\n\nTo modify the behavior of `StringInput`, subclass it in a new file, `app\u002Finputs\u002Fstring_input.rb`:\n\n```ruby\n  class StringInput \u003C Formtastic::Inputs::StringInput\n    def to_html\n      puts \"this is my modified version of StringInput\"\n      super\n    end\n  end\n```\n\nAnother way to modify behavior is by using the input generator:\n```shell\n$ rails generate formtastic:input string --extend\n```\n\nThis generates the file `app\u002Finputs\u002Fstring_input.rb` with its respective content class.\n\nYou can use your modified version with `:as => :string`.\n\n### Creating New Inputs Based on Existing Ones\n\nTo create your own new types of inputs based on existing inputs, the process is similar. For example, to create `FlexibleTextInput` based on `StringInput`, put the following in `app\u002Finputs\u002Fflexible_text_input.rb`:\n\n```ruby\n  class FlexibleTextInput \u003C Formtastic::Inputs::StringInput\n    def input_html_options\n      super.merge(:class => \"flexible-text-area\")\n    end\n\n    def options\n      super.merge(hint: 'This is a flexible text area')\n    end\n  end\n```\n\nYou can also extend existing input behavior by using the input generator:\n\n```shell\n$ rails generate formtastic:input FlexibleText --extend string\n```\n\nThis generates the file `app\u002Finputs\u002Fflexible_text_input.rb` with its respective content class.\n\nYou can use your new input with `:as => :flexible_text`.\n\n### Creating New Inputs From Scratch\n\nTo create a custom `DatePickerInput` from scratch, put the following in `app\u002Finputs\u002Fdate_picker_input.rb`:\n\n```ruby\n  class DatePickerInput\n    include Formtastic::Inputs::Base\n    def to_html\n      # ...\n    end\n  end\n```\n\nYou can use your new input with `:as => :date_picker`.\n\n\n## Dependencies\n\nThere are none other than Rails itself, but...\n\n* If you want to use the `:country` input, you'll need to install the [country-select plugin](https:\u002F\u002Fgithub.com\u002Fcountries\u002Fcountry_select) (or any other country_select plugin with the same API).\n* There are a bunch of development dependencies if you plan to contribute to Formtastic\n\n\n## How to contribute\n\nSee `CONTRIBUTING.md`\n\n\n## Project Info\n\nFormtastic was created by [Justin French](https:\u002F\u002Fjustinfrench.com) with contributions from around 180 awesome developers. Run `git shortlog -n -s` to see the awesome.\n\nThe project is hosted on Github: [https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic](https:\u002F\u002Fgithub.com\u002Fformtastic\u002Fformtastic), where your contributions, forkings, comments, issues and feedback are greatly welcomed.\n\nCopyright (c) 2007-2025, released under the MIT license.\n\n","Formtastic 是一个用于 Ruby on Rails 应用程序的表单构建插件，它能够生成语义丰富且易于访问的 HTML 表单。该项目通过提供一套强大的 DSL（领域特定语言），极大地简化了创建美观、结构清晰、易于样式化和高度可访问性的表单的过程。支持多种输入类型如文本框、单选按钮等，并能灵活地定义表单布局与分组。特别适合需要快速开发高质量用户界面的 Rails 项目，尤其是在那些重视无障碍设计的应用场景中。此外，Formtastic 还兼容多种 ActiveModel 类似的 ORM 和对象，虽然主要针对 ActiveRecord 设计。",2,"2026-06-11 03:14:05","top_language"]