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

Array fields for general data types in the Content Type Builder plugin #1125

Closed
1 task
ghost opened this issue May 5, 2018 · 9 comments
Closed
1 task
Assignees
Labels
status: duplicate Is a duplicate of another issue

Comments

@ghost
Copy link

ghost commented May 5, 2018

What is the expected behavior?

How can I create multiple items (array) in the number or string fields in Content Type Builder plugin?
I want same key name/different value pairs, like as array or list.
I want to put multiple datas in one field like as current media field ( It has the option of “Allow multiple files”.)
I selected mongodb as database.
I already was suggested to create new plugin, but I am not expert to handle that.
So with current Content Type Builder, How can I implement following feature.
For example, Product Content has final sold price field with array value, and it is keeping update from client side’s API call. And this is related to Customer content, one Customer can have many Products, one Product can have many Customers.

Can I implement this database and API with this current Strapi CMS ?

I really want to use this CMS for implementing this feature. what is the solution?
Thank you.


  • I'm sure that this issue hasn't already been referenced.
@enoy
Copy link

enoy commented May 5, 2018

I also often need to create multiple items (array or list) in the number/string/text/media fields in Content Type Builder plugin. Is there a way to do this?

@raulriera
Copy link
Contributor

I also often need to create multiple items (array or list) in the number/string/text/media fields in Content Type Builder plugin. Is there a way to do this?

As a workaround, why not create a new contentType and set the relationship of one to many? A little bit of boilerplate, but doable today

@ghost
Copy link
Author

ghost commented May 7, 2018

I think it will increase complexity, if there is many items to be listed as array to even base data type such as string and number.

@lauriejim lauriejim added issue: feature request Issue suggesting a new feature severity: medium If it breaks the basic use of the product but can be worked around labels May 7, 2018
@Aurelsicoko
Copy link
Member

You're right, currently, this kind of field (array) is complicated to handle with Strapi... I suggest voting for the Plugin - Matrix/Repeater on the vote page. Also, the JSON field could fix the issue in another way...

@lauriejim lauriejim added status: duplicate Is a duplicate of another issue and removed severity: medium If it breaks the basic use of the product but can be worked around issue: feature request Issue suggesting a new feature labels Jun 5, 2018
@lauriejim
Copy link
Contributor

Related #784 #1313

@BertelsBenjamin
Copy link

I see this post dates back from 2018. However, the solution is to choose JSON and when filling in the actual data, just write an array like ["one", "two", "three"] and eventually you can get the full json response by going to localhost:1337/products. You'll see that it returns an array.
Note: "/products" can be any name you gave to a content-type of course.

@congthang1
Copy link

@BertelsBenjamin how to edit this array like $pull or $push?

@PaulSinghDev
Copy link

PaulSinghDev commented Feb 12, 2023

I found the simplest solution to be to just have a short text field and add a regex validator ^[a-zA-Z0-9 ]+(?:,[a-zA-Z0-9 ]+)*$. Then, when I fetch the result I can just .split(',') the field to have a proper array.

EDIT: The reason I opted for this was to allow people less savvy with editing a raw JSON to have simple means of adding in SEO keywords to a post/page

@benramsay
Copy link

benramsay commented May 17, 2023

@BertelsBenjamin
usually the content manager, is managed by other people who aren't really used to writing Json semantics.
The best is to be able to add a set of variables of a given base type. This will generate the json behind, to store in the DB.
This should be a very useful plugin for Strapi. Is not it?
thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate Is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

9 participants