diff options
author | Xavier Noria <fxn@hashref.com> | 2011-07-23 12:15:41 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-07-23 12:15:41 +0200 |
commit | ace3723d2fcb1a96d51c2c82050594129328d7c0 (patch) | |
tree | d95d16b7dfee13037987913ed71d1708b5484f15 /actionpack/lib/action_view/helpers/form_helper.rb | |
parent | 94978b9a46173b875bcb0d5cb724e5119e4aa8f4 (diff) | |
parent | 38310ab1a6f559860e25b0e28bef9560bb452ae6 (diff) | |
download | rails-ace3723d2fcb1a96d51c2c82050594129328d7c0.tar.gz rails-ace3723d2fcb1a96d51c2c82050594129328d7c0.tar.bz2 rails-ace3723d2fcb1a96d51c2c82050594129328d7c0.zip |
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 3a30263b49..724fe7a518 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -49,7 +49,7 @@ module ActionView # <label for="person_last_name">Last name</label>: # <input id="person_last_name" name="person[last_name]" size="30" type="text" /><br /> # - # <input id="person_submit" name="commit" type="submit" value="Create Person" /> + # <input name="commit" type="submit" value="Create Person" /> # </form> # # As you see, the HTML reflects knowledge about the resource in several spots, @@ -80,7 +80,7 @@ module ActionView # <label for="person_last_name">Last name</label>: # <input id="person_last_name" name="person[last_name]" size="30" type="text" value="Smith" /><br /> # - # <input id="person_submit" name="commit" type="submit" value="Update Person" /> + # <input name="commit" type="submit" value="Update Person" /> # </form> # # Note that the endpoint, default values, and submit button label are tailored for <tt>@person</tt>. @@ -233,7 +233,7 @@ module ActionView # <% end %> # # If your resource has associations defined, for example, you want to add comments - # to the post given that the routes are set correctly: + # to the document given that the routes are set correctly: # # <%= form_for([@document, @comment]) do |f| %> # ... @@ -859,7 +859,28 @@ module ActionView InstanceTag.new(object_name, method, self, options.delete(:object)).to_radio_button_tag(tag_value, options) end - # Returns a text_field of type "search". + # Returns an input of type "search" for accessing a specified attribute (identified by +method+) on an object + # assigned to the template (identified by +object_name+). Inputs of type "search" may be styled differently by + # some browsers. + # + # ==== Examples + # + # search_field(:user, :name) + # # => <input id="user_name" name="user[name]" size="30" type="search" /> + # search_field(:user, :name, :autosave => false) + # # => <input autosave="false" id="user_name" name="user[name]" size="30" type="search" /> + # search_field(:user, :name, :results => 3) + # # => <input id="user_name" name="user[name]" results="3" size="30" type="search" /> + # # Assume request.host returns "www.example.com" + # search_field(:user, :name, :autosave => true) + # # => <input autosave="com.example.www" id="user_name" name="user[name]" results="10" size="30" type="search" /> + # search_field(:user, :name, :onsearch => true) + # # => <input id="user_name" incremental="true" name="user[name]" onsearch="true" size="30" type="search" /> + # search_field(:user, :name, :autosave => false, :onsearch => true) + # # => <input autosave="false" id="user_name" incremental="true" name="user[name]" onsearch="true" size="30" type="search" /> + # search_field(:user, :name, :autosave => true, :onsearch => true) + # # => <input autosave="com.example.www" id="user_name" incremental="true" name="user[name]" onsearch="true" results="10" size="30" type="search" /> + # def search_field(object_name, method, options = {}) options = options.stringify_keys @@ -878,17 +899,29 @@ module ActionView end # Returns a text_field of type "tel". + # + # telephone_field("user", "phone") + # # => <input id="user_phone" name="user[phone]" size="30" type="tel" /> + # def telephone_field(object_name, method, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("tel", options) end alias phone_field telephone_field # Returns a text_field of type "url". + # + # url_field("user", "homepage") + # # => <input id="user_homepage" size="30" name="user[homepage]" type="url" /> + # def url_field(object_name, method, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("url", options) end # Returns a text_field of type "email". + # + # email_field("user", "address") + # # => <input id="user_address" size="30" name="user[address]" type="email" /> + # def email_field(object_name, method, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("email", options) end |