Class: UiBibz::Ui::Core::Navigations::ToolbarForm
- Includes:
- ActionView::Helpers, Haml::Helpers, SimpleForm::ActionViewExtensions::FormHelper, Helpers::UtilsHelper
- Defined in:
- lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb
Overview
Create a ToolbarForm
This element is an extend of ActionView::Helpers::FormHelper::FormFor to Rails
Attributes
-
content- Content of element -
options- Options of element -
html_options- Html Options of element
Options
You can add HTML attributes using the html_options. You can pass arguments in options attribute:
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for
# and
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag
Signatures
UiBibz::Ui::Core::Navigations::ToolbarForm.new( = nil, = nil) do |f|
f.text_field :field
f.submit 'Submit'
end
Examples
UiBibz::Ui::Core::Navigations::ToolbarForm.new(position: :right) do |f|
f.text_field :field
f.submit 'Submit'
end.render
UiBibz::Ui::Core::Navigations::ToolbarForm.new('/search', type: :form_tag) do
text_field_tag :field
submit_tag 'Submit'
end.render
Instance Attribute Summary collapse
-
#html_options ⇒ Object
Returns the value of attribute html_options.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(model_or_url, options = {}, &block) ⇒ ToolbarForm
constructor
A new instance of ToolbarForm.
-
#render ⇒ Object
Render html tag.
Methods included from Helpers::UtilsHelper
Methods inherited from Base
#generate_id, #i18n_set?, #inject_url
Constructor Details
#initialize(model_or_url, options = {}, &block) ⇒ ToolbarForm
Returns a new instance of ToolbarForm.
51 52 53 54 55 56 57 |
# File 'lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb', line 51 def initialize(model_or_url, = {}, &block) init_haml_helpers @content = block @model_or_url = model_or_url @options = @html_options = %i[form_for ui_form_for].exclude?(type) ? (@model_or_url, new_option) : new_option end |
Instance Attribute Details
#html_options ⇒ Object
Returns the value of attribute html_options.
49 50 51 |
# File 'lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb', line 49 def @html_options end |
Instance Method Details
#render ⇒ Object
Render html tag
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb', line 60 def render case type when :form_for @form = form_for(@model_or_url, , &@content) when :ui_form_for begin @form = ui_form_for(@model_or_url, , &@content) rescue e raise 'You must install simple form to use ui_form_for.' end else @form = form_tag_with_body(, capture(&@content)) end end |