Method: Scrivito::BasicWidget.new

Defined in:
app/cms/scrivito/basic_widget.rb

.new(attributes = {}, context = {}) ⇒ Widget

Note:

Note that creating a widget does not implicitly persist it. The widget is only persisted if its creation is part of the creation of the object containing it, or as the object or widget containing it is updated.

Creates a new Widget. The defaults set via Widget.default_for are taken into account.

Parameters:

  • attributes (Hash) (defaults to: {})

    for the new widget

  • context (Hash) (defaults to: {})

    in which the object creating should happen

Options Hash (context):

Returns:

Raises:

  • (ArgumentError)

    if called on Widget without _obj_class attribute.

See Also:


148
149
150
151
152
153
154
# File 'app/cms/scrivito/basic_widget.rb', line 148

def self.new(attributes = {}, context = {})
  if obj_class = extract_obj_class_from_attributes(attributes)
    obj_class.new(attributes, context)
  else
    super(build_attributes_with_defaults(attributes, context))
  end
end