Created
September 8, 2012 23:30
-
-
Save oniram/3681054 to your computer and use it in GitHub Desktop.
app/inputs/custom_input.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app/inputs/custom_input.rb | |
class DatePickerInput | |
include Formtastic::Inputs::Base | |
def to_html | |
<input type="text" class="custom"> | |
end | |
end | |
=begin E para usar seu componente customizado basta colocar :as = :custom onde :custom é o prefixo do seu componente | |
customizado definido no arquivo custom.input.rb | |
=end | |
#apps/views/seuform.html.erb | |
f.input :nome, :as => :custom | |
=begin | |
Você pode também passar outras opções e acessá-las no arquivo de definição do seu componente através de: self.options[:suaopcao], como no meu exemplo | |
=end | |
#app/inputs/custom_input.rb | |
class DatePickerInput | |
include Formtastic::Inputs::Base | |
def to_html | |
<input type="text" class="self.options[:classe]"> | |
end | |
end | |
#apps/views/seuform.html.erb | |
f.input :nome, :as => :custom, :classe => "classe_custom" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment