Kiss A simpler, smarter web application framework for Ruby

Kiss::Form::MultiChoiceField Subclass of Kiss::Form::Field

Description

—— MultiChoiceField

Public Instance Methods

matched_options(value) source

Not documented

    # File lib/kiss/form/field.rb, line 287
      def matched_options(value)
        value = [value].flatten
        @options_value_key ?
          @options.select {|o| value.select {|v| o[@options_value_key] == v } }.flatten :
          @options.select {|o| value.select {|v| o == v } }.flatten
      end
    
option_pairs() source

Not documented

    # File lib/kiss/form/field.rb, line 278
      def option_pairs
        (defined? @options_value_key) ?
          @options.map {|option| [ option[@options_value_key], option[@options_display_key] ]} :
          begin
            @display_format = @format
            @options.map {|option| [ option, option ] }
          end
      end
    
validate() source

Not documented

    # File lib/kiss/form/field.rb, line 294
      def validate
        if @other && param == 'other'
          @param = @form.params[@name+'.other']
        end
        super('select')
        
        if @value =~ /\S/ && matched_options(@value).size == 0
          add_error "Invalid selection" 
        end
      end
    

Disabled; run with $DEBUG to generate this.