bureaucrat 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -393,17 +393,13 @@ module Fields
393
393
  end
394
394
 
395
395
  def valid_value?(value)
396
- @choices.each do |k, v|
397
- if v.is_a?(Array)
398
- # This is an optgroup, so look inside the group for options
399
- v.each do |k2, v2|
400
- return true if value == k2.to_s
401
- end
396
+ @choices.any? do |k, v|
397
+ if v.is_a?(Array) # This is an optgroup, so look inside the group for options
398
+ v.any? {|k2, v2| value == k2.to_s}
402
399
  else
403
- return true if value == k.to_s
400
+ value == k.to_s
404
401
  end
405
402
  end
406
- false
407
403
  end
408
404
  end
409
405
 
@@ -34,7 +34,7 @@ module Bureaucrat; module Forms
34
34
  attrs[:id] ||= auto_id if auto_id && !widget.attrs.key?(:id)
35
35
 
36
36
  if !@form.bound?
37
- data = @form.initial.fetch(@name, @field.initial)
37
+ data = @form.initial.fetch(@name.to_s, @field.initial)
38
38
  data = data.call if data.respond_to?(:call)
39
39
  else
40
40
  if @field.is_a?(Fields::FileField) && @data.nil?
@@ -5,6 +5,7 @@ module Quickfields
5
5
  include Fields
6
6
 
7
7
  def hide(name)
8
+ base_fields[name] = base_fields[name].dup
8
9
  base_fields[name].widget = Widgets::HiddenInput.new
9
10
  end
10
11
 
@@ -12,6 +13,10 @@ module Quickfields
12
13
  field name, CharField.new(options)
13
14
  end
14
15
 
16
+ def text(name, options={})
17
+ field name, CharField.new(options.merge(:widget => Widgets::Textarea.new))
18
+ end
19
+
15
20
  def password(name, options={})
16
21
  field name, CharField.new(options.merge(:widget => Widgets::PasswordInput.new))
17
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bureaucrat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Deferrari