Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Cannot edit content in nested sections, only adding works #4

Open
spackmat opened this issue Apr 21, 2017 · 11 comments
Open

Cannot edit content in nested sections, only adding works #4

spackmat opened this issue Apr 21, 2017 · 11 comments
Labels

Comments

@spackmat
Copy link

Q A
Bug report? yes
Feature request? no
PHP version 5.6
TYPO3 version 7.6.18
TemplaVoilà version 7.6.4

Actual and expected behaviour

I have a quice compex FCE with nested sections. The outer section holds the link categories of a linklist, the inner section the links. The XML created by TemplaVoilà looks like this (I only implemented the needed fields to better reproduce this):

example of nested sections.txt

I only fixed the <script> of the link field (as mentioned in #2 ) and the <title> and <type> tags of section and containers as described in the breaking changes documentation, so that they are shown in the form. Btw: the xml created by Templavoilà should put the <title> tags of sections and containers to the correct place outside of the <tx_templavoila> tag.

When I create a new content element with this FCE, I can add link categories and within them also links. When I save this content-element, the data is correctly stored in the database and shown in the rendered frontend-output. So far, all works as expected.

But when I edit this content element again, the links are gone. The categories are still there and I can also add new links, but when I save them, they are added to the still existing but invisible other links and also not shown in the form.

Steps to reproduce the behaviour

  • create a FCE with a section inside another section (you can use the provided XML)
  • create content with this FCE filling the nesting with test data
  • save and edit it again: the inner elements are not editable nor visible at all, but the content is still there, as you ca see in the preview.
@alexanderschnitzler
Copy link
Owner

There is a good chance that this is already fixed with 25e2592. This commit does fix the missing array for containers when saving/creating data structures.

@spackmat
Copy link
Author

spackmat commented Apr 22, 2017

Hi, I did a quick test and patched the two lines: this doesn't fix the problem, neither did an upgrade to release 7.6.5.

@spackmat
Copy link
Author

spackmat commented Apr 24, 2017

Just a quick question: What is the new correct XML-Code for containers and snippets? Where must the <type> and the <title> tags be? Maybe I misunderstood the migration-docs?

@alexanderschnitzler
Copy link
Owner

Let me add some historical context to this issue which will then explain, why I don't have a quick answer.

First of all, I didn't plan to make the administration module available at all. I wanted a solution for all the people that had existing installations to be able to upgrade to TYPO3 7.6.

I realized that a lot of people actually want to use TV even for new projects or at least adjust existing page templates/elements. That's when I tried to structure the code that is responsible for creating data structures. There is a clean seperation of controller and view.

During that refactoring I needed to try different structures and realized, that the new form engine didn't behave like before in enough ways so I'd be forced to adjust the structure of the flexforms.
I did this months ago and forgot about the very details.

What I know for sure is, that if you have regular elements (no container/section), you are not allowed to put more than 1 child element into the <el> tag. Normally, TV put the title, tx_templavoila and TCEfoms in there. To cope with that limitation, I decided to put all the metadata into the tx_templavoila tag and remove the whole tag during the process of generating editing forms in the backend. It's a change during runtime, which is not saved to the record.

During that change I accidently wrote a wrong documentation. Obviously, containers are expected to have the title tag outside the tx_templavoila tag, not inside.

The type tag needs to follow similar rules. A container needs a <type>array</type> to be recognized as such. A section needs to have the <section>1</section> tag and I think that it must not have a <type>array</type> tag which was different before (<= 6.2).

This explanation does not replace a proper documentation and maybe even an xsd. However, time!

What I have planned for this week, is to see what structure an old 4.5 creates, what my current version does, compare these and define rules.

I'll shortly tell you why I have that time issue. Two weeks ago I was in hospital for a surgery. The weeks before I spent quite a lot of time in the hospital for diagnosis and my journey continues. I am not about to die but I am required to make my hospital visits a priority. Then, there is the time I need for my job to not run out of money. Then, there is this work on templavoila, which is not financed any more by sponsors.

This doesn't mean I will stop the maintenance, actually the opposite is the case, but at the moment I am having a hard time finding a proper time frame to fix these bugs.

If you yourself have some spare time and are willing to help, I'd be very happy to any kind of help. I mentioned my plans to create that flexform definition by comparing an old version with a current one. If I had any data regarding that topic, I could more easily focus on the fixes and documentation.

btw: you are the only one so far that is using this issue tracker. I setup a Gitlab for the sponsors, which they used for month now. In there, I have a bunch of open issues as well. All the versions from 7.6.1 til now are based on reports from my sponsors which I worked on with a higher priority.

All this is not to be meant as an excuse but an explanation for why it's hard to expect quick results. I hope you can understand my struggles a bit and have some patience. :)

@spackmat
Copy link
Author

I didn't want to hurry you, time is limited and priorities change. So please understand my input as input. :) And good luck with your medical condition.

I am now reading into Flexforms documentation to find out, what's the currently correct definition. Maybe, I can contribute something, but my time slot for that is rather short. Do you have some suggestions, where I should read, there are many documentation places.

At the moment, I see many of those exceptions:

Broken data structure on field name tx_templavoila_flex. section without type or vice versa is not allowed

Have a nice day and thanks for your explanation.

@alexanderschnitzler
Copy link
Owner

alexanderschnitzler commented Apr 24, 2017

if (isset($dataStructureSheetElementDefinition['type']) 
    && $dataStructureSheetElementDefinition['type'] === 'array' 
    && isset($dataStructureSheetElementDefinition['section']) 
    && $dataStructureSheetElementDefinition['section'] === '1'
) {
    // A section
    ...
} elseif (isset($dataStructureSheetElementDefinition['type']) || isset($dataStructureSheetElementDefinition['section'])) {
    throw new \UnexpectedValueException(
         'Broken data structure on field name ' . $fieldName . '. section without type or vice versa is not allowed',
        1440685208
    );

    // A "normal" TCA element
} else {
   ...

This is the part where the flexform is evaluated. From that we can derive the rule that it's only allowed to have a type tag when there is a section tag as well, thus defining a section.

Honestly I am a little bit confused by this myself. ^^

Besides that, I guess you won't find an updated version of the flexform definition in the official docs. At least I didn't find any which drove me mad during the development.

@alexanderschnitzler
Copy link
Owner

Alright, I had some time to dig into all this and it doesn't look good.

First of all, I created a new data structure in TYPO3 4.5 with an old version of templavoila:

flexform.xml
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
  <meta type="array">
      <langDisable>1</langDisable>
  </meta>
  <ROOT type="array">
      <tx_templavoila type="array">
          <title>ROOT</title>
          <description>Select the HTML element on the page which you want to be the overall container element for the
              template.
          </description>
      </tx_templavoila>
      <type>array</type>
      <el type="array">
          <field_container type="array">
              <type>array</type>
              <tx_templavoila type="array">
                  <title>Container</title>
                  <eType>none</eType>
                  <TypoScript></TypoScript>
                  <proc type="array">
                      <int>0</int>
                      <HSC>0</HSC>
                      <stdWrap></stdWrap>
                  </proc>
                  <preview></preview>
              </tx_templavoila>
              <TCEforms type="array">
                  <label></label>
                  <config type="array">
                  </config>
              </TCEforms>
              <el type="array">
                  <field_text type="array">
                      <tx_templavoila type="array">
                          <title>Text</title>
                          <sample_data type="array">
                              <numIndex index="0"></numIndex>
                          </sample_data>
                          <eType>input</eType>
                          <TypoScript type="NULL"></TypoScript>
                          <proc type="array">
                              <int>0</int>
                              <HSC>1</HSC>
                              <stdWrap></stdWrap>
                          </proc>
                          <preview></preview>
                      </tx_templavoila>
                      <TCEforms type="array">
                          <label>Text</label>
                          <config type="array">
                              <type>input</type>
                              <size>48</size>
                              <eval>trim</eval>
                          </config>
                      </TCEforms>
                  </field_text>
                  <field_container type="array">
                      <type>array</type>
                      <tx_templavoila type="array">
                          <title>Nested Container</title>
                          <eType>input</eType>
                          <TypoScript></TypoScript>
                          <proc type="array">
                              <int>0</int>
                              <HSC>0</HSC>
                              <stdWrap></stdWrap>
                          </proc>
                          <preview></preview>
                      </tx_templavoila>
                      <TCEforms type="array">
                          <label></label>
                          <config type="array">
                          </config>
                      </TCEforms>
                      <el type="array">
                          <field_text type="array">
                              <tx_templavoila type="array">
                                  <title>Text</title>
                                  <sample_data type="array">
                                      <numIndex index="0"></numIndex>
                                  </sample_data>
                                  <eType>input</eType>
                                  <proc type="array">
                                      <HSC>1</HSC>
                                      <stdWrap></stdWrap>
                                      <int>0</int>
                                  </proc>
                                  <preview></preview>
                                  <TypoScript type="NULL"></TypoScript>
                              </tx_templavoila>
                              <TCEforms type="array">
                                  <label></label>
                                  <config type="array">
                                      <type>input</type>
                                      <size>48</size>
                                      <eval>trim</eval>
                                  </config>
                              </TCEforms>
                          </field_text>
                      </el>
                  </field_container>
              </el>
          </field_container>
          <field_section type="array">
              <type>array</type>
              <tx_templavoila type="array">
                  <title>Section</title>
                  <eType>input</eType>
                  <preview></preview>
              </tx_templavoila>
              <el type="array">
                  <field_text type="array">
                      <tx_templavoila type="array">
                          <title>Text</title>
                          <sample_data type="array">
                              <numIndex index="0"></numIndex>
                          </sample_data>
                          <eType>input</eType>
                          <proc type="array">
                              <HSC type="integer">1</HSC>
                              <stdWrap></stdWrap>
                          </proc>
                          <preview></preview>
                          <TypoScript type="NULL"></TypoScript>
                      </tx_templavoila>
                      <TCEforms type="array">
                          <label>Text</label>
                          <config type="array">
                              <type>input</type>
                              <size>48</size>
                              <eval>trim</eval>
                          </config>
                      </TCEforms>
                  </field_text>
                  <field_section type="array">
                      <type>array</type>
                      <tx_templavoila type="array">
                          <title>Nested Section</title>
                          <eType>input</eType>
                          <preview></preview>
                      </tx_templavoila>
                      <el type="array">
                          <field_text type="array">
                              <tx_templavoila type="array">
                                  <title>Text</title>
                                  <sample_data type="array">
                                      <numIndex index="0"></numIndex>
                                  </sample_data>
                                  <eType>input</eType>
                                  <proc type="array">
                                      <HSC type="integer">1</HSC>
                                      <stdWrap></stdWrap>
                                  </proc>
                                  <preview></preview>
                                  <TypoScript type="NULL"></TypoScript>
                              </tx_templavoila>
                              <TCEforms type="array">
                                  <label>Text</label>
                                  <config type="array">
                                      <type>input</type>
                                      <size>48</size>
                                      <eval>trim</eval>
                                  </config>
                              </TCEforms>
                          </field_text>
                      </el>
                      <section>1</section>
                  </field_section>
              </el>
              <section>1</section>
          </field_section>
          <field_notmapped type="array">
              <type>no_map</type>
              <tx_templavoila type="array">
                  <title>Not Mapped</title>
                  <sample_data type="array">
                      <numIndex index="0"></numIndex>
                  </sample_data>
                  <eType>input</eType>
                  <proc type="array">
                      <HSC>1</HSC>
                      <stdWrap></stdWrap>
                      <int>0</int>
                  </proc>
                  <preview></preview>
                  <TypoScript type="NULL"></TypoScript>
              </tx_templavoila>
              <TCEforms type="array">
                  <label>Not Mapped</label>
                  <config type="array">
                      <type>input</type>
                      <size>48</size>
                      <eval>trim</eval>
                  </config>
              </TCEforms>
          </field_notmapped>
          <field_element type="array">
              <tx_templavoila type="array">
                  <title>Element</title>
                  <sample_data type="array">
                      <numIndex index="0"></numIndex>
                  </sample_data>
                  <eType>input</eType>
                  <proc type="array">
                      <HSC type="integer">1</HSC>
                      <stdWrap></stdWrap>
                  </proc>
                  <preview></preview>
                  <TypoScript type="NULL"></TypoScript>
              </tx_templavoila>
              <TCEforms type="array">
                  <label>Element</label>
                  <config type="array">
                      <type>input</type>
                      <size>48</size>
                      <eval>trim</eval>
                  </config>
              </TCEforms>
          </field_element>
          <field_attribute type="array">
              <type>attr</type>
              <tx_templavoila type="array">
                  <title>Attribute</title>
                  <sample_data type="array">
                      <numIndex index="0"></numIndex>
                  </sample_data>
                  <eType>input</eType>
                  <proc type="array">
                      <HSC type="integer">1</HSC>
                      <stdWrap></stdWrap>
                  </proc>
                  <preview></preview>
                  <TypoScript type="NULL"></TypoScript>
              </tx_templavoila>
              <TCEforms type="array">
                  <label>Attribute</label>
                  <config type="array">
                      <type>input</type>
                      <size>48</size>
                      <eval>trim</eval>
                  </config>
              </TCEforms>
          </field_attribute>
      </el>
  </ROOT>
</T3DataStructure>

I used that structure and put it into a TYPO3 7.6 with the a templavoila 7.6.5.

Now, we have to have a look at two different things:

  1. How that structure is renderer by the form engine (i.e. editing a page/content record)
  2. How that structure is interpreted by the templavoila data structure editor.

The Form Engine

The form engine changed a lot regarding the rendering of flexforms. There are some facts that are worth mentioning:

  1. Nested sections are not supported any more.
  2. Nested containers are not supported any more. This also means, that one cannot use containers inside the root container. One can only use containers inside sections.
  3. Sections cannot hold simple elements directly any more. Sections hold containers, that hold simple elements.

There is the extension styleguide, which is kind of an official documentation about what kind of flexform structures are supported.

The TemplaVoila data structure editor

The editor didn't really change compared to the old versions of TemplaVoilà. Pretty much the same rules apply. That's the reason why one can still build nested structures with it, that can also be rendered in the frontend (because TemplaVoilà does the rendering) but cannot be edited in the backend.

What's the solution?

Well, there is no quick solution at all. I spoke to the core team member that did the implementation of the new form engine. He says, the core dropped nested containers and sections and that there is noone willing to bring that back.

Further he said, that it would take a huge amount of time to bring that into the core. One needs to write all the tests and the code needs to be accepted by core devs.

Another option is to implement all that in TemplaVoilà. I could do so, but currently I do not have the funds to do so.

There is one option I'd like to go with instead: Replace the flexforms with yaml and implement an independent rendering. This would take even more time, but it would be a much cleaner implementation because then TemplaVoilà does not overwrite core classes any more.

However, I don't know what to do exactly now. What I know for sure, is that there will not be any quick solution. On top of that, I know that there are more problems ahead in TYPO3 8.7.

I'll think about all that and maybe come up with another crowdfunding campaign.

@spackmat
Copy link
Author

Thanks for your information.

Phew, that is quite frustrating. In my case, most of the FCEs use nested sections and I cannot change that easyly, as there is a huge amount of content relying on that.

But then, I wonder why the nestes sections still work well, when they are created, just the editing of exiting content doesn't work anymore. If the nested sections were removed from the core, this should not work at all. Or is this TemplaVoilà handling the form here?

@alexanderschnitzler
Copy link
Owner

But then, I wonder why the nestes sections still work well, when they are created

Do you mean why they can be created in the templavoila module? If so, that's what I tried to explain. That part is pure templavoila code, without any core stuff involved.

just the editing of exiting content doesn't work anymore

That's where the form engine of the core plays its role and conflicts with the created structures.

@spackmat
Copy link
Author

The thing is, that I can create new content correctly. All form elements of the nested sections work as expected. When I save the content element, the new inserted content is not visible in the form, but was persisted to the database and is rendered in the frontend and the preview. When I add new content to those nested sections, it is added to the existing content, but also not visible in the form anymore.

The effect is, that I can add new content, but cannot edit or delete old content in nested sections.

@alexanderschnitzler
Copy link
Owner

I see. I did implement all the changes from compatibility6 into templavoila itself, so your TYPO3 7.6 behaves like a 6.2 version. Things fixes some things but breaks others. I thought that the code, that was taken from compatibility6, would be more stable.

Basically, I have a burning house and try to fight the small flames here and there but even if it seems like things are working partly, there is always something wrong.

The changes from comaptibility6 bring back multi language flexforms but distort the reality. In fact the structure you are working with doesn't work and with comaptibility6 it just seems to work better.

However, the handling is broken and needs to be fixed either way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants