{
    "mode": "ri",
    "parameter": "ActionView::Helpers::FormOptionsHelper",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/ri/ActionView%3A%3AHelpers%3A%3AFormOptionsHelper/json",
    "generated": "2026-07-25T04:38:40Z",
    "sections": {
        "ActionView::Helpers::FormOptionsHelper": {
            "content": "------------------------------------------------------------------------",
            "subsections": []
        },
        "Includes:": {
            "content": "TextHelper (from /home/chedong/.local/share/rdoc)\n\nERB::Util can mask some helpers like textilize. Make sure to include\nthem.\n\n(from /home/chedong/.local/share/rdoc)\n------------------------------------------------------------------------\nProvides a number of methods for turning different kinds of containers\ninto a set of option tags.\n\nThe collectionselect, select and timezoneselect methods take an\noptions parameter, a hash:\n\n* :includeblank - set to true or a prompt string if the first option\nelement of the select element is a blank. Useful if there is not a\ndefault value required for the select element.\n\nselect(\"post\", \"category\", Post::CATEGORIES, { includeblank: true })\n\ncould become:\n\n<select name=\"post[category]\" id=\"postcategory\">\n<option value=\"\" label=\" \"></option>\n<option value=\"joke\">joke</option>\n<option value=\"poem\">poem</option>\n</select>\n\nAnother common case is a select tag for a belongsto-associated\nobject.\n\nExample with @post.personid => 2:\n\nselect(\"post\", \"personid\", Person.all.collect { |p| [ p.name, p.id ] }, { includeblank: 'None' })\n\ncould become:\n\n<select name=\"post[personid]\" id=\"postpersonid\">\n<option value=\"\">None</option>\n<option value=\"1\">David</option>\n<option value=\"2\" selected=\"selected\">Eileen</option>\n<option value=\"3\">Rafael</option>\n</select>\n\n* :prompt - set to true or a prompt string. When the select element\ndoesn't have a value yet, this prepends an option with a generic\nprompt -- \"Please select\" -- or the given prompt string.\n\nselect(\"post\", \"personid\", Person.all.collect { |p| [ p.name, p.id ] }, { prompt: 'Select Person' })\n\ncould become:\n\n<select name=\"post[personid]\" id=\"postpersonid\">\n<option value=\"\">Select Person</option>\n<option value=\"1\">David</option>\n<option value=\"2\">Eileen</option>\n<option value=\"3\">Rafael</option>\n</select>\n\n* :index - like the other form helpers, select can accept an :index\noption to manually set the ID used in the resulting output. Unlike\nother helpers, select expects this option to be in the htmloptions\nparameter.\n\nselect(\"album[]\", \"genre\", %w[rap rock country], {}, { index: nil })\n\nbecomes:\n\n<select name=\"album[][genre]\" id=\"albumgenre\">\n<option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option>\n</select>\n\n* :disabled - can be a single value or an array of values that will be\ndisabled options in the final output.\n\nselect(\"post\", \"category\", Post::CATEGORIES, { disabled: 'restricted' })\n\ncould become:\n\n<select name=\"post[category]\" id=\"postcategory\">\n<option value=\"joke\">joke</option>\n<option value=\"poem\">poem</option>\n<option disabled=\"disabled\" value=\"restricted\">restricted</option>\n</select>\n\nWhen used with the collectionselect helper, :disabled can also be a\nProc that identifies those options that should be disabled.\n\ncollectionselect(:post, :categoryid, Category.all, :id, :name, { disabled: -> (category) { category.archived? } })\n\nIf the categories \"2008 stuff\" and \"Christmas\" return true when the\nmethod archived? is called, this would return:\n<select name=\"post[categoryid]\" id=\"postcategoryid\">\n<option value=\"1\" disabled=\"disabled\">2008 stuff</option>\n<option value=\"2\" disabled=\"disabled\">Christmas</option>\n<option value=\"3\">Jokes</option>\n<option value=\"4\">Poems</option>\n</select>\n------------------------------------------------------------------------",
            "subsections": []
        },
        "Instance methods:": {
            "content": "collectioncheckboxes\ncollectionradiobuttons\ncollectionselect\ngroupedcollectionselect\ngroupedoptionsforselect\noptiongroupsfromcollectionforselect\noptionsforselect\noptionsfromcollectionforselect\nselect\ntimezoneoptionsforselect\ntimezoneselect\n",
            "subsections": []
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}