{"action":"created","issue":{"url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/156","labels_url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/156/comments","events_url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/156/events","html_url":"https://github.com/FluidTYPO3/fluidcontent/issues/156","id":33831724,"number":156,"title":"string in place of array causing problem with for loop","user":{"login":"bednee","id":6805379,"avatar_url":"https://avatars.githubusercontent.com/u/6805379?v=3","gravatar_id":"","url":"https://api.github.com/users/bednee","html_url":"https://github.com/bednee","followers_url":"https://api.github.com/users/bednee/followers","following_url":"https://api.github.com/users/bednee/following{/other_user}","gists_url":"https://api.github.com/users/bednee/gists{/gist_id}","starred_url":"https://api.github.com/users/bednee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bednee/subscriptions","organizations_url":"https://api.github.com/users/bednee/orgs","repos_url":"https://api.github.com/users/bednee/repos","events_url":"https://api.github.com/users/bednee/events{/privacy}","received_events_url":"https://api.github.com/users/bednee/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-05-19T20:04:03Z","updated_at":"2015-10-09T08:26:05Z","closed_at":"2014-06-13T13:57:50Z","body":"I've just came across a possible bug in Fluidcontent. But it's also\r\npossible that I'm doing something wrong.\r\n\r\nThe important part of BE configuration is like this:\r\n\r\n```xml\r\n<f:section name=\"Galerie\">\r\n        <flux:flexform.object name=\"content\">\r\n            <flux:flexform.section name=\"videa\">\r\n                <f:render section=\"Videa\" arguments=\"{_all}\"/>\r\n            </flux:flexform.section>\r\n            <f:if condition=\"{videa -> no1:count()}\">\r\n                <flux:flexform.grid>\r\n                    <f:for each=\"{videa}\" as=\"object\">\r\n                        <flux:flexform.grid.row>\r\n                            <flux:flexform.grid.column>\r\n                                {object.url}\r\n                            </flux:flexform.grid.column>\r\n                        </flux:flexform.grid.row>\r\n                    </f:for>\r\n                </flux:flexform.grid>\r\n            </f:if>\r\n        </flux:flexform.object>\r\n    </f:section>\r\n```\r\n\r\nThen for FE there's:\r\n\r\n```xml\r\n<f:if condition=\"{galerie.content.videa -> f:count()}\">\r\n                        <f:for each=\"{galerie.content.videa}\" as=\"video\">\r\n                            <div class=\"video\">\r\n                                <f:cObject\r\ntyposcriptObjectPath=\"plugin.tx_no1.settings.video\">{video.video.url}</f:cObject>\r\n                            </div>\r\n                        </f:for>\r\n                    </f:if>\r\n```\r\n\r\nThe thing is that I have 2 galleries where only 1 contains some video\r\n(I've stripped out images that are next to the videos). And since it's\r\nempty, the Flexform in database looks like:\r\n\r\n```xml\r\n<field index=\"videa\">\r\n<el index=\"el\">\r\n</el>\r\n</field>\r\n```\r\nwhile in non empty it's\r\n```xml\r\n<field index=\"videa\">\r\n<el index=\"el\">\r\n    <section index=\"1\">\r\n        <itemType index=\"video\">\r\n            <el>\r\n                <field index=\"url\">\r\n                    <value index=\"vDEF\">http://....</value>\r\n                </field>\r\n                <field index=\"id\">\r\n                    <value index=\"vDEF\">4ee64132213cdda37d71e445237327c3f269ba67</value>\r\n                </field>\r\n            </el>\r\n        </itemType>\r\n        <itemType index=\"_TOGGLE\">0</itemType>\r\n    </section>\r\n</el>\r\n</field>\r\n```\r\nAnd the problem is that when I debug {galerie.content.videa} I get 2 values:\r\n\r\n'  ' (41 chars)\r\n\r\nand\r\n\r\narray(1 item)\r\n   1 => array(1 item)\r\n\r\nAs you can see, the whitespace in the first empty element is translated\r\ninto string, which then passes the if - count and goes into f:for\r\ncausing exception.\r\n\r\nAm I doing something wrong?\r\n\r\nFor now I've resolved it by my own CountViewHelper, which tests whether\r\nvalue is array. But that's not a good solution.\r\n\r\nPS: It's 6.2.0"},"comment":{"url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/comments/146795566","html_url":"https://github.com/FluidTYPO3/fluidcontent/issues/156#issuecomment-146795566","issue_url":"https://api.github.com/repos/FluidTYPO3/fluidcontent/issues/156","id":146795566,"user":{"login":"cdominpxp","id":14347480,"avatar_url":"https://avatars.githubusercontent.com/u/14347480?v=3","gravatar_id":"","url":"https://api.github.com/users/cdominpxp","html_url":"https://github.com/cdominpxp","followers_url":"https://api.github.com/users/cdominpxp/followers","following_url":"https://api.github.com/users/cdominpxp/following{/other_user}","gists_url":"https://api.github.com/users/cdominpxp/gists{/gist_id}","starred_url":"https://api.github.com/users/cdominpxp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdominpxp/subscriptions","organizations_url":"https://api.github.com/users/cdominpxp/orgs","repos_url":"https://api.github.com/users/cdominpxp/repos","events_url":"https://api.github.com/users/cdominpxp/events{/privacy}","received_events_url":"https://api.github.com/users/cdominpxp/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T08:26:05Z","updated_at":"2015-10-09T08:26:05Z","body":"I have the same problem with Typo3 7.5.0, Flux 7.2.3, Fluidcontent 4.3.2.\r\n\r\nMy configuration:\r\n```xml\r\n<flux:form id=\"testfce\" options=\"{Fluidcontent: {sorting: 10}, group: 'FCE'}\" label=\"Box\" description=\"Box Description\">\r\n    <flux:form.sheet name=\"contents\" label=\"Text und Bild\">\r\n        <flux:field.inline.fal name=\"falimages\" multiple=\"1\" maxItems=\"1\" enabledControls=\"{info:1,new:1,dragdrop:1,sort:1,hide:1}\" expandSingle=\"1\" label=\"Bild\"/>\r\n        <flux:field.text name=\"text\" label=\"Text\" enableRichText=\"true\" />\r\n    </flux:form.sheet>\r\n    <flux:form.sheet name=\"downloads\" label=\"Downloads\">\r\n        <flux:field.checkbox name=\"hideinfos\" label=\"Dateiinformationen (Format / Größe) ausblenden?\" />\r\n        <flux:field.inline.fal name=\"falfiles\" multiple=\"1\" maxItems=\"5\" enabledControls=\"{info:1,new:1,dragdrop:1,sort:1,hide:1}\" expandSingle=\"1\" label=\"Downloads\"/>\r\n    </flux:form.sheet>\r\n    <flux:form.sheet name=\"linksheet\" label=\"Linkliste\">\r\n        <flux:form.section name=\"linklist\" label=\"Linkliste\">\r\n            <flux:form.object name=\"links\" label=\"Link\">\r\n                <flux:field.input name=\"link\" label=\"Link\">\r\n                    <flux:wizard.link activeTab=\"page\" />\r\n                </flux:field.input>\r\n                <flux:field.input name=\"title\" label=\"Titel\"\" />\r\n            </flux:form.object>\r\n        </flux:form.section>\r\n    </flux:form.sheet>\r\n</flux:form>\r\n```\r\n\r\nValue in pi_flexform after deleting all entries:\r\n```xml\r\n<sheet index=\"linksheet\">\r\n\t<language index=\"lDEF\">\r\n\t\t<field index=\"linklist\">\r\n\t\t\t<el index=\"el\">\r\n\t\t\t</el>\r\n\t\t</field>\r\n\t</language>\r\n</sheet>\r\n```\r\nIMHO the linebreak in the empty el Element is the problem. It should be\r\n```xml\r\n<el index=\"el\"/>\r\n```\r\nIf I change it in the pi_flexform field by hand, everything is fine and {linklist} is empty\r\n\r\nI’ve tried it with the isArray ViewHelper in my template:\r\n```xml\r\n<v:condition.type.isArray value=\"{linklist}\">\r\n\t<f:if>\r\n\t\tIS ARRAY\r\n\t</f:if>\r\n\t<f:else>\r\n\t\tNO ARRAY\r\n\t</f:else>\r\n</v:condition.type.isArray>\r\n```\r\nBut even if the sheet has entries, it returns always: NO ARRAY\r\n\r\nI've tried it with a hacky workaround in MiscellanousUtility.php in cleanFormXml function:\r\n```php\r\nif (trim($containerNode->nodeValue) == '') {\r\n\t$containerNode->nodeValue = '';\r\n}\r\n```\r\nWorks, but i am sure there is a better solution."}}