Class: Formtastic::Inputs::HiddenInput

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/formtastic/inputs/hidden_input.rb

Overview

Outputs a simple <input type="hidden"> wrapped in the standard <li> wrapper. This is provided for situations where a hidden field needs to be rendered in the flow of a form with many inputs that form an <ol>. Wrapping the hidden input inside the <li> maintains the HTML validity. The <li> is marked with a class of hidden so that stylesheet authors can hide these list items with CSS (formtastic.css does this out of the box).

Examples:

Full form context, output and CSS


<%= semantic_form_for(@something) do |f| %>
  <%= f.inputs do %>
    <%= f.input :secret, :as => :hidden %>
  <% end %>
<% end %>

<form...>
  <fieldset>
    <ol>
      <li class="hidden">
        <input type="hidden" id="something_secret" name="something[secret]">
      </li>
    </ol>
  </fieldset>
</form>

form.formtastic li.hidden { display:none; }

See Also:

  • InputsHelper#input for full documentation of all possible options.

Instance Attribute Summary

Attributes included from Base

#builder, #method, #object, #object_name, #options, #template

Instance Method Summary collapse

Methods included from Base

#initialize, #removed_option!, #warn_and_correct_option!, #warn_deprecated_option!

Methods included from Base::Wrapping

#input_wrapping, #wrapper_classes, #wrapper_classes_raw, #wrapper_dom_id, #wrapper_html_options, #wrapper_html_options_raw

Methods included from Base::Labelling

#label_from_options, #label_html, #label_html_options, #label_text, #localized_label, #render_label?, #requirement_text, #requirement_text_or_proc

Methods included from LocalizedString

#model_name

Methods included from Base::Associations

#association, #association_primary_key, #belongs_to?, #has_many?, #reflection

Methods included from Base::Fileish

#file?

Methods included from Base::Validations

#autofocus?, #column_limit, #limit, #not_required_through_negated_validation!, #not_required_through_negated_validation?, #optional?, #required?, #required_attribute?, #responds_to_global_required?, #validation_integer_only?, #validation_limit, #validation_max, #validation_min, #validation_step, #validations, #validations?, #validator_relevant?

Methods included from Base::Naming

#as, #attributized_method_name, #humanized_method_name, #input_name, #sanitized_method_name, #sanitized_object_name

Methods included from Base::Hints

#hint_text, #hint_text_from_options

Methods included from Base::Errors

#error_first_html, #error_keys, #error_list_html, #error_none_html, #error_sentence_html, #errors

Methods included from Base::Database

#column, #column?

Methods included from Base::Options

#formtastic_options, #input_options

Methods included from Base::Html

#dom_id, #dom_index

Instance Method Details

#error_htmlObject



44
45
46
# File 'lib/formtastic/inputs/hidden_input.rb', line 44

def error_html
  ""
end

#errors?Boolean



48
49
50
# File 'lib/formtastic/inputs/hidden_input.rb', line 48

def errors?
  false
end

#hint?Boolean



56
57
58
# File 'lib/formtastic/inputs/hidden_input.rb', line 56

def hint?
  false
end

#hint_htmlObject



52
53
54
# File 'lib/formtastic/inputs/hidden_input.rb', line 52

def hint_html
  ""
end

#input_html_optionsObject



34
35
36
# File 'lib/formtastic/inputs/hidden_input.rb', line 34

def input_html_options
  super.merge(:required => nil).merge(:autofocus => nil)
end

#to_htmlObject



38
39
40
41
42
# File 'lib/formtastic/inputs/hidden_input.rb', line 38

def to_html
  input_wrapping do
    builder.hidden_field(method, input_html_options)
  end
end