strapi / strapi

šŸš€ Strapi is the leading open-source headless CMS. Itā€™s 100% JavaScript/TypeScript, fully customizable and developer-first.
https://strapi.io
Other
61.01k stars 7.61k forks source link

Adding new custom field types #483

Closed niallobrien closed 5 years ago

niallobrien commented 6 years ago

Hi, I'd like to explore the possibility of creating new field types to further expand what's already within Strapi. How would I go about this?

Thanks in advance.

Node.js version: 8.9.0 npm version: 5.5.1 Strapi version: 3.0.0-alpha.6.7 Operating system: Windows 7 Enterprise

soupette commented 6 years ago

Hi @niallobrien you'll have to modify the content-type-builder plugin and the content-manager plugins. In order to do so you have to start your project in development mode

Steps to display your new input in the content type builder

Use your new type in the content manager

Adding a new type is not optimal at the moment you might have to modify the core of this two plugins.

niallobrien commented 6 years ago

Thanks for the info. Are there plans to make this process more modular in the future?

soupette commented 6 years ago

Well we're currently working on the upload, but since the Input Library has been redone it should be normally easier to create new types (for the front end part), you'll will just have to edit a json file if the GUI doesn't contain it already. However it's not on our short-term road map to allow to create custom field from the GUI šŸ—šŸ—..

UserGalileo commented 6 years ago

Hi guys! I'm looking at Strapi cause I really need a new Headless CMS, I like a LOT of things I've seen in Strapi but this feature in particular would be essential and could be a game changer in the CMS scenario.

In particular, what I'd need is the "Location" field, a-la Contentful.

If this enhancement is difficult to implement (I believe so), could I ask if you could include a location field type soon? Thanks, and compliments!

n1mos commented 6 years ago

I'm also considering to use Strapi but I don't feel confident using it without a feature to add custom field types...

This is a must.

n1mos commented 6 years ago

@UserGalileo Did you find a solution for this or did you choose other CMS?

UserGalileo commented 6 years ago

@Daekan I donā€™t need it right now, but Iā€™m also looking at graphCMS which should implement that feature and itā€™s GraphQL based :) Iā€™m keeping an eye on both!

victorkane commented 6 years ago

The great virtue of Strapi.io is that it is a completely open source CMS. This practically doesn't really exist in today's world, believe it or not. They all want to keep your stuff in the cloud behind a paywall and give you toys, like graphCMS, like contentful and others or else are oldish or directly abandoned, like Keystone. Strapi.io is open, I've just started using it and I'm amazed at how it creates my API automatically, including the basic code. You can even develop templates and use these from the command line generator. Also, the road is open to develop and make pull requests (I only hope I'll be able to do this in the future). So I don't think it's fair to compare something like graphCMS (completely behind a paywall) and a community driven open source project.

UserGalileo commented 6 years ago

@victorkane GraphCMS is going open source this month with the beta release for testing and they are doing an awesome job to improve the platform :) You can look at what they're doing on the Slack channel.

So yeah, after they go open source, the comparison will be fair. Also, don't forget the services that Contentful (for example) gives you: the Sync API alone justifies the cost for me. And this is something totally managed, totally handled by their servers. They offer different services which live "behind that paywall" :)

jsamr commented 6 years ago

@UserGalileo Unfortunately, the backend will remain closed (from their slack): image

Aurelsicoko commented 6 years ago

I remember that GraphCMS relies on GraphCool, so they can't open their backend. Also, it doesn't make sense for them to do that. Their business model hasn't been thought about a full open-source strategy in mind like we're doing...

harmjanluth commented 5 years ago

Anyway.. +1 for custom fields. Mandatory feature.

Clonk-HTML5 commented 5 years ago

+1 for custom fields. Mandatory feature.

bkd705 commented 5 years ago

+1 for this one. Would be open to assisting in implementation, am a bit new to Strapi however so some direction would be wonderful if possible.

MWalid commented 5 years ago

+1 too

soupette commented 5 years ago

@bkd705 do you mean adding a new type of field in the content-type-builder or customising the content-manager with new fields?

cliqer commented 5 years ago

@soupette IMHO any solution to make it easier to add custom fields to users would be great. Right now if I add an Image field to the user I have problems reading it back with the strapi-sdk in nuxt.

roonie007 commented 5 years ago

+1

selected-pixel-jameson commented 5 years ago

+1

Aurelsicoko commented 5 years ago

This feature will be implemented. Please upvote and give us more insights via Product Board (https://portal.productboard.com/strapi/c/10-custom-fields).

steampixel commented 5 years ago

+1

derrickmehaffy commented 5 years ago

@steampixel if you haven't already you can also send your support on the product board page as well :)

Smiling-bishop commented 5 years ago

Hi @niallobrien you'll have to modify the content-type-builder plugin and the content-manager plugins. In order to do so you have to start your project in development mode

Steps to display your new input in the content type builder

  • To display your new field you'll have to add it in the /plugins/content-type-builder/admin/src/containers/Form/forms.jsonfile.
  • You'll have to add the corresponding translations in the /plugins/content-type-builder/admin/src/translations folder
  • From now on you're able to display your new attribute in the plugin (this might have an impact on the plugin's component)
  • You won't have to modify the actions or reducer of the plugin's front-end part.

Use your new type in the content manager

  • In the content manager plugin you'll have to modify the Edit container and its children in order to display your new field type.
  • You'll have to either create a new input type in the strapi-helper-plugin/src/components/Input/index.js file or a new Input directly in your plugin's admin/src/components folder and import it in the content-manager/admin/src/admin/components/EditForm/index.js file.

Adding a new type is not optimal at the moment you might have to modify the core of this two plugins.

Hi,

I try your way but when, on the admin, I add the custom field and save, the server stopped. There is the error: UnhandledPromiseRejectionWarning: TypeError: Invalid value for schema path Email.type

I look to where the schema is generated and I can't find it. I'm start strapi with MongoDB and looking to have custom field in Object format.

Thanks,

cwahlfeldt commented 5 years ago

+1 need this so I can kill off wordpress + acf please šŸ‘

ChristopherDosin commented 5 years ago

So in fact currently it's not really possible to create custom content fields?

derrickmehaffy commented 5 years ago

@ChristopherDosin possible yes. difficult also yes. deployment after creation? Very difficult. Upgradability on strapi versions and keeping modifications? near impossible at the moment.

ChristopherDosin commented 5 years ago

@derrickmehaffy argh .. okay. Hopefully, those custom fields will come in the near future. Maybe we should start a fundraising for this incredibly useful feature? ^^

derrickmehaffy commented 5 years ago

@ChristopherDosin the problem is not funds, it's lack of outside contributors. The Strapi team is quite busy working on other more important stuff right now. If someone else wanted to take up development of this they are welcome to submit a PR.

ChristopherDosin commented 5 years ago

@derrickmehaffy Understand - I would if i could :) But i am not that Node.js / Strapi / JS Guru to submit such a PR .. :(

derrickmehaffy commented 5 years ago

There are quite a number of other important feature requests as well: https://portal.productboard.com/strapi/tabs/2-under-consideration but I am in the same boat @ChristopherDosin

cwahlfeldt commented 5 years ago

@ChristopherDosin This might be a long shot but... WordPress with the plugins: Advanced Custom Fields and ACF to Rest API. Then use the Rest API to grab data. Not sure how to pull api data to populate a custom strapi field though.

ACF (Advanced Custom Fields) provides all the functionality I would like to see in Strapis custom fields. Obviously its a different architecture and approach but ACF gets it right when it comes to fields. Its worked for every single client Ive served for the last 5 years doing WP dev. The Flexible Content especially allows me to make any data model I need for content creators.

https://www.advancedcustomfields.com/

p.s. rant: This is the most important feature for me and my workflow. This would push Strapi beyond a "possible" solution for my clients, and actually become a viable, real solution that I can sell to business's. With that said I totally understand the team has obligations and more important structural features but without this I cant adopt strapi just yet but, Im hoping I can sooner than later :)

Cheers!

derrickmehaffy commented 5 years ago

p.s. rant: This is the most important feature for me and my workflow. This would push Strapi beyond a "possible" solution for my clients, and actually become a viable, real solution that I can sell to business's. With that said I totally understand the team has obligations and more important structural features but without this I cant adopt strapi just yet but, Im hoping I can sooner than later :)

Trust me, lots of us have "deal breaking" bugs and features we want, hence why I would like to see other contributors with higher skills sets than myself help build the features they want. This is an open source project after all :wink: (I'm not a member of the Strapi team)

lapphan commented 5 years ago

Will it possible to add a custom field type like "ValueWithUnit" with this future feature? Currently I manage to do it in Strapi with JSON field: { "value": 14 "unit": "mm", } and can filter it through GraphQL endpoint. But it will be nice if we can have a custom filed type to display it properly in Content Manager screen. It's empty now: image

Aurelsicoko commented 5 years ago

Yes, we rewrote the plugin to accept custom field in the future. We don't support it for now but don't worry we have this feature in mind.

dhniels commented 4 years ago

I see this is closed, was this feature added?

derrickmehaffy commented 4 years ago

@dhniels It has not, if you see here: https://github.com/strapi/strapi/issues/483#issuecomment-437675592

It was moved over to the Feature Request tracking (ProductBoard)

sheerun commented 4 years ago

Still not implemented?

ChristopherDosin commented 4 years ago

Still not implemented?

No, but you can contribute if you have some good ideas how to get started šŸ˜‰

sheerun commented 4 years ago

Any tips?

danielbidala commented 4 years ago

Hi. I'm on laravel at the moment but thinking to learn node.js. I've found strapi today and it seems very promising but without custom form field types and custom list column types it's unusable for my projects.

Now I use October CMS for backend apps, it's based on laravel so I think it's not an option for you guys. It has all the feature you missing from strapi in this issue. I hope custom fields and list column types will be implemented.

arbaouimehdi commented 4 years ago

@ChristopherDosin This might be a long shot but... WordPress with the plugins: Advanced Custom Fields and ACF to Rest API. Then use the Rest API to grab data. Not sure how to pull api data to populate a custom strapi field though.

ACF (Advanced Custom Fields) provides all the functionality I would like to see in Strapis custom fields. Obviously its a different architecture and approach but ACF gets it right when it comes to fields. Its worked for every single client Ive served for the last 5 years doing WP dev. The Flexible Content especially allows me to make any data model I need for content creators.

https://www.advancedcustomfields.com/

p.s. rant: This is the most important feature for me and my workflow. This would push Strapi beyond a "possible" solution for my clients, and actually become a viable, real solution that I can sell to business's. With that said I totally understand the team has obligations and more important structural features but without this I cant adopt strapi just yet but, Im hoping I can sooner than later :)

Cheers!

Custom fields are the most important aspect of having better control over the app by adding multiple and different forms of content. I'm really not 100% into Strapi because of custom fields, I love to see this feature in the near future.

lauriejim commented 4 years ago

Hello, an update about this topic. This coming step by step.

"Currently, we have added this feature to the administration panel (documentation here) which is the first step to the adding custom fields to your project. It works great if you add them manually but the content-type-builder does not support it yet."

cc @soupette author of this quote.

beve commented 4 years ago

@lauriejim Yeah, great news ! It really the killer feature i was expecting to switch to Strapi for my projects.

Thanks for all this work.

lichaar commented 4 years ago

@lauriejim @soupette Really looking forward to this, Finally Strapi is coming to a stage which can be used for much more projects.

SuperMasterBlasterLaser commented 4 years ago

@lauriejim

Is it possible to create custom field based on existing fields like jsonfield? I wan't to create new type of field and assign it to my content types

lauriejim commented 3 years ago

Hello! It's not possible to create a new field, but your can update the JSON field that currently exist in Strapi to make it matches your need. Here is an example with the WYSIWYG input.

guanghw commented 3 years ago

For the momentļ¼Œcreate new field by customized jsonfieldļ¼Œ is good idea!but it's limited ,a project can only have one custom field,i think may jsonfiled have an optional attribute,like 'subtype' or else,then our customize field can use this for show a different look

ghost commented 3 years ago

Is this still not possible? For example with a plugin? I try to create a plugin for a new type of field ,but it doesn't show up in the field selector.

derrickmehaffy commented 3 years ago

Is this still not possible? For example with a plugin? I try to create a plugin for a new type of field ,but it doesn't show up in the field selector.

You can't currently inject new fields into the content-type builder but you can add custom fields manually. For example see: https://www.paulgaumer.com/blog/how-to-create-a-color-picker-plugin-for-strapi-cms

Just note that the columnType needs to match a data type for your database. Attempting to modify a model with a custom field set manually through the .json config will throw errors and likely break the model.

rullymartanto commented 2 years ago

I have try that tutorial but when I am using version 3.6.5 it won't work I think because this issue image

in version 3.2.5 image and this is work there is any help ?