Last active
February 13, 2017 20:23
-
-
Save altherlex/c8d6c2f3d89750c551be to your computer and use it in GitHub Desktop.
Simple_form in show
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
#config/initializers/simple_form/description_component.rb | |
module SimpleForm | |
module Components | |
# Needs to be enabled in order to do automatic lookups | |
module Description | |
# Name of the component method | |
def desc(wrapper_options = nil) | |
object.send(attribute_name) if @builder.instance_variable_get('@lookup_action') == :show | |
end | |
end | |
end | |
end | |
SimpleForm::Inputs::Base.send(:include, SimpleForm::Components::Description) |
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
<%= simple_form_for @universe, html:{ role:"form"} do |f| %> | |
<%= nav_menu do |m| %> | |
<%= link_to 'Edit', edit_universe_path(@universe), class:"btn btn-primary active", role:'button'%> | |
<%= link_to 'Back', universes_path, type:"button", class:"btn btn-default" %> | |
<%end%> | |
<p id="notice"><%= notice %></p> | |
<%= f.input :name, :wrapper => :bs %> | |
<%end%> | |
<!-- | |
#out html | |
<div class="form-group"> | |
<label class="col-sm-2 control-label">Name</label> | |
<div class="col-sm-10"> | |
<p class="form-control-static">First Query</p> | |
</div> | |
</div> | |
--> |
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
#config/initializers/simple_form.rb | |
config.wrappers :bs, :tag => 'div', :class => 'form-group' do |b| | |
b.use :html5 | |
b.use :placeholder | |
b.use :label_text, :tag=> 'label', :class => 'col-sm-2 control-label' | |
b.use :readonly | |
b.wrapper :tag => 'div', :class => 'col-sm-10' do |ba| | |
ba.use :readonly | |
ba.use :desc, :tag=>'p', :class => 'form-control-static' | |
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' } | |
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not simply
app/inputs/static_input.rb
and then