Details
-
Bug
-
Resolution: Duplicate
-
High
-
5.0.0-dev
-
None
Description
If you have a xmltext field type and have '$fieldAttr->isRequired = true;' it is not possible to create a object if that field type
I have tried to set the value in 3 different ways
$content->setField( 'xmltext', '<?xml version="1.0" encoding="utf-8"?> <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"><paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">This is a object test</paragraph></section>' );
$xmlDoc = new DOMDocument(); $xmlDoc->loadXML( '<?xml version="1.0" encoding="utf-8"?> <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"><paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">This is a object test</paragraph></section>' ); $xmlValue = new eZ\Publish\Core\FieldType\XmlText\Value( $xmlDoc ); $content->setField( 'xmltext', $xmlValue );
$xmlInputConverter = new eZ\Publish\Core\FieldType\XmlText\Converter\Input\EzXml( "../vendor/ezsystems/ezpublish/eZ/Bundle/EzPublishCoreBundle/Resources/schemas/ezxml.xsd" ); $content->setField( 'xmltext', $xmlInputConverter->convert( '<?xml version="1.0" encoding="utf-8"?> <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"><paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">This is a object test</paragraph></section>' ) );
All 3 methods gives exception once I try to publish object with saveContent():
1) eZPublishAPIXMLText::testTC1305CreateXMLTextObject eZ\Publish\Core\Base\Exceptions\ContentValidationException: Required field 'xmltext' value is empty /var/www/apache2php53/ezpublish5/vendor/ezsystems/ezpublish/eZ/Publish/Core/Repository/ContentService.php:542 /var/www/apache2php53/ezpublish5/vendor/ezsystems/ezpublish/eZ/Publish/Core/SignalSlot/ContentService.php:237 /var/www/apache2php53/ezpublish5/ezpublish_testsystem/extension/ezpublishapitests/classes/ezpublishapitesthelper.php:417 /var/www/apache2php53/ezpublish5/ezpublish_testsystem/extension/ezpublishapitests/tests/ezpublishapi/ezpublishapi/datatypes/xmlblock/ezpublishapixmlblock.php:135
Gives exception