Sha256: ba86352f6b2c5a21ff9b536a214a0a761a0fe4407e7914fa4254458492d4cb31
Contents?: true
Size: 1.17 KB
Versions: 53
Compression:
Stored size: 1.17 KB
Contents
module Effective module FormInputs class ErrorField < Effective::FormInput def input_html_options { class: 'alert alert-danger', id: tag_id } end def to_html(&block) return nil unless has_error?(name) case layout when :horizontal build_wrapper do content_tag(:div, '', class: 'col-sm-2') + content_tag(:div, build_error_content, class: 'col-sm-10') end else content_tag(:div, build_error_content, class: 'form-group') end end def build_error_content include_name = include_name? content = ( if name.blank? object.errors.full_messages.to_sentence elsif include_name? object.errors.full_messages_for(name).to_sentence else object.errors.messages[name].to_sentence end ) content_tag(:div, content, options[:input]) end private def include_name? return @include_name unless @include_name.nil? @include_name = options[:input].key?(:include_name) ? options[:input].delete(:include_name) : true end end end end
Version data entries
53 entries across 53 versions & 1 rubygems