2020-04-27, 03:09:12
Hi Bigin,
Thanks for your reply and explaining the various methods how to load the items of type "Item" object
And yes, like you mentioned, I can confirm that this code is now working also:
I believe that the word 'data' in the example above is used as a reference to a field type e.g. a text field
and that data is not a field type by it self. But maybe this is already something obvious to know.
But I am not sure about that because I have seen this somewhere also: $item->fields->color->value
and color is not listed in the list of available field types.
I use the code above like this now with success:
When I go to back end admin => Manager => View All => Category1 => on the bottom of the page
I can see that the new item has been created.
F.
Thanks for your reply and explaining the various methods how to load the items of type "Item" object
And yes, like you mentioned, I can confirm that this code is now working also:
Code:
$imanager = imanager();
$item = new Item(1);
$item->name = 'My item name';
$item->setFieldValue('data', 'Your field value');
$item->save();
I believe that the word 'data' in the example above is used as a reference to a field type e.g. a text field
and that data is not a field type by it self. But maybe this is already something obvious to know.
But I am not sure about that because I have seen this somewhere also: $item->fields->color->value
and color is not listed in the list of available field types.
I use the code above like this now with success:
Code:
$imanager = imanager();
$item = new Item(1); // create a new item in Category 1, this new item gets automatically the fields already setup in Category 1
$item->name = 'next item'; // give the new created item a name
$item->setFieldValue('text', 'Hello world');
$item->save(); // Go to the admin => Manager => view all and check if a new item was created
$item = imanager()->getItem(1, 'name=next item');
echo $item->fields->text->value; // check that output is what was saved: Hello world
When I go to back end admin => Manager => View All => Category1 => on the bottom of the page
I can see that the new item has been created.
F.