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-selection branch from 6691dbe to 1833f67 Compare November 9, 2020 13:35
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.

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 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