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

[Example] Add selection content-type for custom entity #85

Draft
wants to merge 1 commit into
base: example/custom-entity
Choose a base branch
from

Conversation

niklasnatter
Copy link
Contributor

@niklasnatter niklasnatter commented Nov 2, 2020

What's in this PR?

This PR demonstrates how to add a selection and single_selection content-type for a custom entity. The content-types allow to select one or multiple entities inside of a page template or a form. This PR builds upon #84.

Have a look at the Extend Admin UI documentation for more information about the changes in this PR.

Screenshot 2020-10-30 at 16 42 00

To use the content-types, you need to add a property with the respective type to a page template or a form:

<property name="single_event_selection" type="single_event_selection">
    <meta>
        <title lang="en">Single Event Selection</title>
    </meta>
</property>
<property name="event_selection" type="event_selection">
    <meta>
        <title lang="en">Event Selection</title>
    </meta>
</property>

@niklasnatter niklasnatter changed the base branch from master to example/custom-entity November 2, 2020 08:56
@niklasnatter niklasnatter added the Example Example implementations label Nov 2, 2020
@niklasnatter niklasnatter force-pushed the example/custom-entity branch 2 times, most recently from 92dd780 to 2138884 Compare November 9, 2020 13:30
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 2aec0f3 to 6691dbe Compare November 9, 2020 13:31
@sulu sulu deleted a comment from alexander-schranz Nov 9, 2020
@sulu sulu deleted a comment from alexander-schranz Nov 9, 2020
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 2138884 to 19b7d58 Compare November 9, 2020 13:35
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 6691dbe to 1833f67 Compare November 9, 2020 13:35
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 1833f67 to 85d3e59 Compare November 27, 2020 16:01
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 85d3e59 to 08303ca Compare November 30, 2020 16:01
list_key: 'events'
display_properties:
- 'name'
icon: 'su-calendar'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Available icons are documented in the Sulu Javascript Docs.

@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 08303ca to b0f648b Compare December 18, 2020 10:46
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from cd4fe57 to 3a052f7 Compare January 25, 2021 09:06
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from b0f648b to e799f6d Compare January 25, 2021 09:07
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 3a052f7 to 3ccf457 Compare January 29, 2021 14:37
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from e799f6d to ec0e009 Compare January 29, 2021 14:38
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 3ccf457 to 737467e Compare February 3, 2021 09:45
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from ec0e009 to b82d5f1 Compare February 3, 2021 09:47
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 737467e to 2f49214 Compare February 3, 2021 10:18
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from b82d5f1 to fb2f9c3 Compare February 3, 2021 10:19
Comment on lines +51 to +52
App\Content\Type\SingleEventSelection:
tags: [ { name: 'sulu.content.type', alias: 'single_event_selection' } ]

App\Content\Type\EventSelection:
tags: [ { name: 'sulu.content.type', alias: 'event_selection' } ]
Copy link
Contributor Author

@niklasnatter niklasnatter Feb 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a field-type is used inside of a page template, Sulu looks for a content-type that matches the name of the field-type. A content-type is registered as Symfony service and is responsible for loading and storing the data of the field to the page.

If a field-type is not used inside of page templates, it is not necessary to implement a matching content-type.

@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from fb2f9c3 to a93855f Compare February 16, 2021 14:36
@niklasnatter niklasnatter force-pushed the example/custom-entity branch 2 times, most recently from d052269 to 7265b30 Compare February 16, 2021 14:38
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from a93855f to 98a4703 Compare February 16, 2021 14:39
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 98a4703 to 7016f60 Compare February 26, 2021 10:32
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 7016f60 to c6aa14d Compare March 22, 2021 15:44
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 69b1e17 to 46a3a42 Compare April 26, 2021 11:46
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from c6aa14d to b79ad69 Compare April 26, 2021 11:47
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 46a3a42 to 66a3d03 Compare May 12, 2021 15:30
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from b79ad69 to 7f1b513 Compare May 12, 2021 15:30
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 66a3d03 to 18cd7be Compare June 20, 2022 17:42
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from 7f1b513 to a051e72 Compare June 20, 2022 17:43
@niklasnatter niklasnatter force-pushed the example/custom-entity-selection branch from a051e72 to b1bb926 Compare June 20, 2022 17:58
types:
list_overlay:
adapter: 'table'
list_key: 'events'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reference the already existing events.xml: here: https://github.com/sulu/sulu-demo/blob/example/custom-entity/config/lists/events.xml

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

Successfully merging this pull request may close these issues.

2 participants