This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Public API - Create ContentObjects

Public API - Create ContentObjects

Public API - Create ContentObjects

Monday 27 October 2014 3:15:43 pm - 2 replies

Hi eZ-Forum,

i have some problems working with the new public API. Creating content with this api is not very well documented but i managed most of the needed things till now. 

I am trying to create a poll but it seems like there is some work in progress from the eZ Team.

I am trying the following code:

$contentType = $contentTypeService->loadContentTypeByIdentifier( 'poll' );
$contentCreateStruct = $contentService->newContentCreateStruct( $contentType, 'ger-DE');
$contentCreateStruct->setField('name', 'Testpoll');
$questionval = new \eZ\Publish\Core\FieldType\Null\Value( $this->question );
$contentCreateStruct->setField('question', 'Test' );
$contentCreateStruct->setField('question', 'Testquestion' );

If i do it this way (setting question as a string), i will get an invalid argument error:

Argument '$value' is invalid: expected value to be of type 'eZ\Publish\Core\FieldType\Null\Value', got 'string'

So it seems like questions has to be a nulltype, because using 

 $contentCreateStruct->setField('question', $questionval );

throws no errors (but don't helps me very much blunk.gif Emoticon).

Also it is very disappointing to work with the nice new api but to run into serious rtfm hell (should better be called rtfk (read the fucking kernel), if i am trying such non-basic things. Why is there almost no detailed advanced documentation? 

Best regards,


Modified on Monday 27 October 2014 3:18:19 pm by Jacob Ester

Monday 27 October 2014 3:30:57 pm

i'm afraid you can't create a content type having a ezsurvey (is this what you want?) until ezsurvey fieldtype or something equivalent is implemented.

while you can create content having text lines, floats, integer or xml block types, as those fields are already implemented, you'll have to wait for ezsurvey port or trying to do the port yourself.


Monday 27 October 2014 3:53:57 pm

Hi Carlos,

thanks for your answer. No, i am not trying to create an eZSurvey, i just want to create some "simple" poll (this is also the name of the contentclass, which cames in each standard installation of eZ (community and enterprise)). It contains only a question and some answers. So more like a "vote" i would say. I am not sure where eZSurvey plays a role in my question. The name of the contentclassidentifier is poll, the class_identifier of the field is question. I thought eZSurvey is an own extension?

Similiar to this:

Is there any documentation or roadmap of the current available content types or some release plans about the content types which will be implemented in the near future? 

Best regards,



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from