mailr/app/views/common/_input_form_desc_field.html.haml

28 lines
1.1 KiB
Plaintext
Raw Normal View History

2012-03-10 21:03:56 +01:00
- model = eval(object.class.model_name)
2012-03-24 13:23:34 +01:00
- model_string = object.class.model_name.downcase
2012-03-10 21:03:56 +01:00
- label.nil? ? model_label = model.human_attribute_name(attr) : model_label = t(label.to_sym)
2012-03-24 13:23:34 +01:00
- val = value || object.instance_eval(attr) || ""
- if object.errors[attr.to_sym].empty?
2012-03-26 20:22:01 +02:00
- to_class ||= ""
2012-03-24 13:23:34 +01:00
.control-group
%label{:class=>"control-label",:for=>"#{attr}"}
= model_label
.controls
2012-03-26 20:22:01 +02:00
%input{:class=>"#{to_class}",:id=>"#{model_string}_#{attr}",:name=>"#{model_string}[#{attr}]",:value=>"#{val}"}
2012-03-24 13:23:34 +01:00
%p{:class=>"help-block"}
= t(:example,:scope=>:common)
= example
- else
.control-group.error
%label{:class=>"control-label",:for=>"#{attr}"}
= model_label
.controls
%input{:id=>"#{model_string}_#{attr}",:name=>"#{model_string}[#{attr}]",:value=>"#{val}"}
%span{:class=>"help-inline"}
= object.errors[attr.to_sym].to_s
%p{:class=>"help-block"}
= t(:example,:scope=>:common)
= example
-#= render :partial => "common/input_form_desc_field",:locals => {:object => @user,:attr => 'login',:label => nil,:example => 'joe.doe',:value => params[:user] ? params[:user][:login] : "" }