Sha256: a76959e20646d9f96c322082c1d2c54f210bc695cb35e3eb317c6aaeae4c7aa0
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
module ExpressTemplates module Components module Forms class FormComponent < Base include Capabilities::Configurable include Capabilities::Adoptable def compile(*args) raise "#{self.class} requires a parent ExpressForm" if parent.nil? or parent_form.nil? super(*args) end # Lookup the resource_name from the parent ExpressForm. def resource_name parent_form.resource_name end def resource_var resource_name.to_sym end # Return the name attribute for the lable def label_name "#{resource_name.singularize}_#{field_name}" end # Return the text content for the label def label_text @options[:label] || field_name.titleize end # Return the field_name as a string. This taken from the first argument # to the component macro in the template or fragment. def field_name (@config[:id] || (@args.first.is_a?(String) && @args.first)).to_s end # Return the field name attribute. Currently handles only simple attributes # on the resource. Does not handle attributes for associated resources. def field_name_attribute "#{resource_name.singularize}[#{field_name}]" end def field_wrapper_class @config[:wrapper_class] || 'field-wrapper' end # Search the parent graph until we find an ExpressForm. Returns nil if none found. def parent_form @my_form ||= parent until @my_form.nil? || @my_form.kind_of?(ExpressForm) @my_form = @my_form.parent end return @my_form end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
express_templates-0.4.0 | lib/express_templates/components/forms/form_component.rb |