Obj.create(attributes)

Creates a new Obj with the given attributes.

Copy
Scrivito.getClass("BlogPost").create({ title: "Hello world!" })

Params

  • attributes (Object) – The custom attributes and their values of the new CMS object.

Throws

  • ArgumentError – If a given attribute is invalid.

Returns

The created Obj.

Examples

Create a new blog post with a permalink:

Copy
Scrivito.getClass("BlogPost").create({
  _permalink: "scrivito-best-practices",
  title: "How to Make the Best of Scrivito",
});

Create a new page consisting of an initial text widget that says “Hello!”. After creating the page, navigate to the new page:

Copy
Page = Scrivito.getClass('Page');
TextWidget = Scrivito.getClass('TextWidget');

widget = new TextWidget({ text: 'Hello!' });
obj = Page.create({ body: [widget] });

Scrivito.navigateTo(obj);