lib/bureaucrat/forms.rb
# Renders this field with the option of using alternate widgets
# and attributes.
Renders this field with the option of using alternate widgets
and attributes.
Renders this field with the option of using alternate widgets and attributes .
def as_widget(widget=nil, attrs=nil, only_initial=false)
        widget ||= @field.widget
        attrs ||= {}
        auto_id = self.auto_id
        attrs[:id] ||= auto_id if auto_id && !widget.attrs.key?(:id)
        if !@form.bound?
          data = @form.initial.fetch(@name, @field.initial)
          data = data.call if data.respond_to?(:call)
        else
          if @field.is_a?(Fields::FileField) && @data.nil?
            data = @form.initial.fetch(@name, @field.initial)
          else
            data = self.data
          end
        end
        name = only_initial ? @html_initial_name : @html_name
        widget.render(name.to_s, data, attrs)
      end
def as_widget ( widget = nil , attrs = nil , only_initial = false ) widget ||= @field . widget attrs ||= { } auto_id = self . auto_id attrs [ :id ] ||= auto_id if auto_id && ! widget . attrs . key? ( :id ) if ! @form . bound? data = @form . initial . fetch ( @name , @field . initial ) data = data . call if data . respond_to? ( :call ) else if @field . is_a? ( Fields :: FileField ) && @data . nil? data = @form . initial . fetch ( @name , @field . initial ) else data = self . data end end name = only_initial ? @html_initial_name : @html_name widget . render ( name . to_s , data , attrs ) end
Renders this field with the option of using alternate widgets
and attributes.
Renders this field with the option of using alternate widgets and attributes .
widget
<not_specific>
attrs
<not_specific>
only_initial
<not_specific>