cb.objects.create

cb.objects.create

param value example
pid parent object Id. 20
template_id Template id of the object 19
oid
rename into: owner_id
Owner Id 67
data an array of field/values according to template_id see below
date ? the date in SOLR format 2012-03-27T10:25
cdate ? the date in SOLR format (creation date) 2012-03-27T10:25
name ? object title for mysql tree A sample product

Example Response

If operation is successful, the ID of the new object is return in xml/json format:

<objectId>28</objectId>

Data format

{
    // single value field
    field_name1 => 'some text here'

    // single value field with children fields
    field_name2 => array(
        'value'   => 'field value'
        ,'info'   => 'field info'
        ,'childs' => array(
            field_name => FIELD_DEFINITION
            ...
        )
    )

    // simple multiplicated field
    ,field_name3 => array('mymail@home.com', 'name@work.com')


    // multiplicated field with children fields
    ,field_name4 => array(
        array(
            'value' => 'field value'
            ,'info' => 'field info'
            ,'childs' => array(
                field_name => FIELD_DEFINITION
            )
        )

        array(
            'value' => 'field value'
            ,'info' => 'field info'
            ,'childs' => array(
                field_name => FIELD_DEFINITION
            )
        )
    )
}

Class usage

$data = {
    'title'   => 'My first CaseBox object'

    ,'address' => [
        'value' => '4341 Tudor Centre Drive'
        ,'info' => 'entrance behind the yellow building'
    ]

    ,'email' => [
        'mymail@home.com'
        ,['value' => 'name@work.com'
          ,'info' => 'attachment limit is 1Mb'
         ]
    ]

    ,'feature' => [
        [
            'value' => 'Close to metro'
            ,'childs' => [
                'importance' => 'High'
                'date'       => '2014-02-09'
            ]
        ]
        ,[
            'value' => 'Nice kitchen'
            ,'childs' => [
                'importance' => 'Medium'
                'date'       => '2014-01-17'
            ]
        ]
    ]
};



$item = array(
    'pid' => 1                   // adding under the root node
    ,'name' => 'Sample object'   // default name of the object (even if template doesn't define a title)
    ,'template_id' => 7          // one of your templates
    ,'data' => $data
);

$obj = new \CB\Objects\Object();
$newId = $obj->create($item);    // $newId will contain the Id of the newly created object