Method: Scrivito::BasicWidget#initialize

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

#initialize(attributes = {}) ⇒ BasicWidget

Create a new Widget. The new Widget must be stored inside a container (i.e. an Obj or another Widget) before it can be used.

See Obj.create for a detailed overview of how to set attributes.

Examples:

Create a widget using a subclass:

# you can create widgets by explicitly providing the '_obj_class' attribute
new_widget = Widget.new(_obj_class: "MyWidget")
# but it is better to simply use the constructor of a subclass
new_widget = MyWidget.new

Create a widget and store it inside an Obj:

# create the widget
new_widget = Widget.new(_obj_class: "MyWidget")
# store it inside an obj
my_obj(my_widget_field: [new_widget])


122
123
124
125
# File 'app/cms/scrivito/basic_widget.rb', line 122

def initialize(attributes = {})
  @attributes_to_be_saved = self.class.prepare_attributes_for_instantiation(attributes)
  @attribute_cache = {}
end