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 » eZ Publish 5 Platform » Create eztags attribute with PHP

Create eztags attribute with PHP

Create eztags attribute with PHP

Wednesday 22 April 2015 10:20:43 am - 7 replies

Hi there,

I would like to create an eztags attribute with PHP in a class, as shown on the picture below.


As for now, i am able to create the tag attribute but i can only control the common properties : (name, description, required, searchable etc ..)

I would like to be able to create tag with predefined properties :

- Subtree limit
- Hide root subtree
- Show dropdrown
- Max number of tags

I am using the eZ 5 API to create the attributes as follow :

$fieldCreateStruct = $contentTypeService->newFieldDefinitionCreateStruct($attr_identifier, $attr['type']);
$fieldCreateStruct->names = array($attr['language'] => $attr['name']);
$fieldCreateStruct->descriptions = array($attr['language'] => $attr['description']);
$fieldCreateStruct->isRequired = $attr['required'];
$fieldCreateStruct->isSearchable = $attr['searchable'];
$fieldCreateStruct->isInfoCollector = $attr['information_collector'];
$fieldCreateStruct->isTranslatable = $attr['translatable'];
$fieldCreateStruct->fieldGroup = $attr['category'];
$fieldCreateStruct->position = $attr['position'];
$fieldCreateStruct->fieldSettings = $attr['settings'];
$fieldCreateStruct->validatorConfiguration = $attr['validator'];

I guess there are specials fieldSettings and validatorConfiguration to pass, but i couldn't find anything in the doc about tags creation.

I've tried to look at the inputs id and name in the HTML code to "guess" the param name like hide_root_tag => hideRootTag  but nothing worked.

More info :
- Using netgenTagsBundle to create tags
- All tags are created, just need to link them in the classes attributes.

Thanks for your help.

Modified on Wednesday 22 April 2015 5:34:33 pm by Task Mikaël

Wednesday 22 April 2015 12:27:55 pm


It's fun that you ask this now. No later than yesterday, I have started a PR on the CookbookBundle that demonstrates ContentType and FieldDefinition manipulation a bit better happy.gif Emoticon

Validator config and settings are both set using the hashes returned by Type::getValidatorConfigurationSchema() and Type::getSettingsSchema() methods. Unless reimplemented, they return the contents of the Type::$validatorConfigurationSchema and Type::$settingsSchema properties.

The Tags FieldType doesn't differ, and uses the same mechanisms. As far as I can see, the settings have the following structure:

$settingsSchema = array(
  "subTreeLimit" => array( "type" => "int", "default" => 0 ),
  "showDropDown" => array( "type" => "boolean", "default" => false ),
  "hideRootTag" => array( "type" => "boolean", "default" => false ),
  "maxTags" => array( "type" => "int", "default" => 0 )

Setting values for those would look like:

$fieldCreateStruct->fieldSettings = array(</span>
  "subTreeLimit" => 3,
  "showDropDown" => true,
  "hideRootTag" => false,
  "maxTags" => 5

Modified on Wednesday 22 April 2015 12:29:14 pm by Bertrand Dunogier

Wednesday 22 April 2015 5:30:07 pm


It is not working : ContentType FieldDefinitions did not validate


Thursday 23 April 2015 10:03:26 am


Anyone have an idea ? i guess it's because the params in the array are not good, but that's the only clue I Have. That is the last type i have to create, after this I'm done with classes and attributes.

Thanks for you help.

Thursday 23 April 2015 1:21:52 pm

Make sure that you use the exact type for array values. An int inside a string won't do, for instance (just cast).

If it doesn't work, I'm just gonna have to test it myself happy.gif Emoticon

Thursday 23 April 2015 2:27:19 pm


I have tried to cast the values in the array, but it didn't work either.

If you would be so good as to test the feature, it would really be helpful.



Modified on Thursday 23 April 2015 2:36:12 pm by Task Mikaël

Thursday 23 April 2015 3:41:00 pm


Sorry for wasting your time ... i had the oldest version of eztags-ls and netgen bundle ... i completely forgot to upgrade it !

Anyway, problem solved !

Marking the topic as solved.

Friday 24 April 2015 8:42:30 am

Hah, I knew it was odd ! No problem, Mikaël, glad you're able to move on.


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

36 542 Users on board!

Forums menu

Proudly Developed with from