Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Automatic grids from section objects #1582

Merged
merged 3 commits into from
Oct 27, 2018

Conversation

NamelessCoder
Copy link
Member

Adds a flag for section objects to make each object
that gets saved in the section, a content container
column in the page layout view.

Example Form with section-objects-as-grid:

<flux:form id="sectionObjectsAsGrid">
    <flux:form.section name="objects">
        <flux:form.object name="main" contentContainer="1">
            <flux:field.input name="test" label="Test" />
        </flux:form.object>
    </flux:form.section>
</flux:form>

@NamelessCoder NamelessCoder changed the title [FEATURE] Automatic grids from section objects [WIP][FEATURE] Automatic grids from section objects Jul 15, 2018
@NamelessCoder NamelessCoder force-pushed the feature/sectionobjectasgrid branch 5 times, most recently from eb6e95a to 3f6dc05 Compare July 15, 2018 14:21
@NamelessCoder
Copy link
Member Author

This should work now, but has a bit of odd behavior:

  • When creating new instances of the parent, you can create up to two new content areas without causing problems.
  • But when the element is saved once, you can create only one new content area and then have to save the parent - or the colPos value gets duplicated.

The array of existing objects that is received by the user function unfortunately does not contain all objects until you've saved - but does contain one object if the list of objects was previously empty. Go figure - but that's how it works...

We will need the JS solution to update these field values somehow. I can provide the next save colPos value to use - but the JS has to then increment this when new objects are created in the section.

@NamelessCoder
Copy link
Member Author

screen shot 2018-07-15 at 16 34 26
screen shot 2018-07-15 at 16 33 56

@NamelessCoder
Copy link
Member Author

Hidden field for column position and input field for label are added automatically if contentContainer="1" is specified. The rest are the fields that you yourself specify.

@NamelessCoder NamelessCoder force-pushed the feature/sectionobjectasgrid branch 2 times, most recently from de5cae4 to 58c7f3d Compare July 15, 2018 15:04
@yol
Copy link

yol commented Jul 24, 2018

Is it intentional to make the label mandatory? Depending on the type of CE, it might not make sense to put labels on the content areas and it would be better number them (like "Content Area #1") automatically.

@NamelessCoder
Copy link
Member Author

The label is optional (but the field will always be there, perhaps that's what you meant?).

Regarding automatic numbering that comes with the same challenge as the colPos value and the thing this patch attempts to solve - if you move an object in the section, the numbering changes. Outputting the colPos value as label happens if you don't fill the name/label field.

I mostly added it so that all the fields that have a special functionality based on their name (colPos, name) will also have an automatically added form field. The one thing you can't do from within a template is remove this field (that would require a custom Provider or usage of Flux hooks), but if you declare another field with that name, that field will replace the automatic one (logic sequence: is-content-container gets set on section object, fields get added when setter is called, any subsequent additions of a field with the same name replaces that field).

Adds a flag for section objects to make each object
that gets saved in the section, a content container
column in the page layout view.

Example Form with section-objects-as-grid:

    <flux:form id="sectionObjectsAsGrid">
        <flux:form.section name="objects">
            <flux:form.object name="main" contentContainer="1">
                <flux:field.input name="test" label="Test" />
            </flux:form.object>
        </flux:form.section>
    </flux:form>
@NamelessCoder NamelessCoder changed the title [WIP][FEATURE] Automatic grids from section objects [FEATURE] Automatic grids from section objects Oct 27, 2018
@NamelessCoder NamelessCoder merged commit 71a9cdc into development Oct 27, 2018
@poveli
Copy link

poveli commented Jan 21, 2019

How it is possible to render the content of the grids?
<flux:content.render area="content.{iteration.index}" />
is deprecated now.

Thanks for your support!

@apiening
Copy link

apiening commented Apr 9, 2019

How it is possible to render the content of the grids?

<flux:content.render area="{itemObject.main.colPos}" />

worked for me.

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

Successfully merging this pull request may close these issues.

None yet

4 participants