Kiss A simpler, smarter web application framework for Ruby

Kiss::Form::MultiValueField Subclass of Kiss::Form::MultiChoiceField

Description

—— MultiValueField

Public Instance Methods

param() source

Not documented

    # File lib/kiss/form/field.rb, line 340
      def param
        @form.params[@name.to_s+'[]'] || []
      end
    
selected_option_values() source

Not documented

    # File lib/kiss/form/field.rb, line 364
      def selected_option_values
        @selected_option_values ||= @value ? Hash[ *(@value.map {|v| [v.to_s,true]}.flatten) ] : {}
      end
    
validate() source

Not documented

    # File lib/kiss/form/field.rb, line 344
      def validate
        begin
          @value = param.map { |p| @format.validate(p) }
        rescue Kiss::Format::ValidateError => e
          add_error("#{e.message.capitalize}")
          return
        end
        
        if @value.size > 0
          @value.each do |v|
            unless (matched_options(v).size > 0)
              add_error "#Invalid selection"
              return
            end
          end
        elsif @required
          add_error "Please select at least one #{@label}"
        end
      end
    

Disabled; run with $DEBUG to generate this.