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] Create, register and use custom field-type and content-type #79

Draft
wants to merge 1 commit into
base: master
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 implement a custom content type, which can be used inside of page templates and custom entity forms. The example registers a simple currency content type that displays an input with an icon in the administration interface and stores its amount in number of cents on the server.

Have a look at the Sulu Javascript Documentation for more information about the Javascript components and services included in Sulu.

Screenshot 2020-10-06 at 16 46 34

To apply the changes, the administration frontend application needs to be rebuilt by executing bin/console sulu:admin:update-build.

@niklasnatter niklasnatter marked this pull request as draft November 2, 2020 08:48
@niklasnatter niklasnatter added the Example Example implementations label Nov 2, 2020
@alexander-schranz alexander-schranz changed the title [Example] Register and use custom content type in form [Example] Create, register and use custom content and field type Jan 28, 2021
@niklasnatter niklasnatter changed the title [Example] Create, register and use custom content and field type [Example] Create, register and use custom field-type and content-type Feb 12, 2021
@@ -47,3 +47,6 @@ services:

App\Content\Type\AlbumSelection:
tags: [{name: 'sulu.content.type', alias: 'album_selection'}]

App\Content\Type\Currency:
Copy link
Contributor Author

@niklasnatter niklasnatter Feb 18, 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-content-type branch from 99921a6 to 03d032c Compare June 20, 2022 16:24
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.

1 participant