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

Minimum number of rows in Matrix fields #850

Closed
angrybrad opened this issue Jan 31, 2017 · 13 comments
Closed

Minimum number of rows in Matrix fields #850

angrybrad opened this issue Jan 31, 2017 · 13 comments

Comments

@angrybrad
Copy link
Member

Created by: Jérôme Coupé ([email protected]) on 2015/03/12 05:21:11 +0000
Votes at time of UserVoice import: 35


Its is very nice to be able to specify the max number of rows in a Matrix but I think specifying the minimal number of rows would be interesting too in many cases.

By combining those two settings you would be able to create Matrix fields needing 3 and only 3 components. That would give you tighter control over your content model / data structure while letting users benefit from the reordering / add / delete capabilities of Matrix.

Use cases:

  1. a simple grid of icons, titles and text. If your wide screen layout calls for three items or more, there is currently no way to enforce that with Matrix

  2. when building more complex data grids (2 items, 3 items, 4 items per "row") having such a parameter would allow for a simpler data structure while preserving the reorder / add / delete and configure options currently given by Matrix

@angrybrad
Copy link
Member Author

Posted by Stephen McIver ([email protected]) on 2015/04/13 23:58:09 +0000


This would be very useful. Just like you can do with Matrix in EE.

@angrybrad
Copy link
Member Author

Posted by Bryan Garrant ([email protected]) on 2015/12/28 20:55:58 +0000


This would be great

Min Blocks
The minimum number of blocks the field is allowed to have

@brandonkelly
Copy link
Member

To improve the AX, Matrix fields with less than the minimum should get placeholder blocks instead of the Add Block buttons. Placeholder blocks just show a list of the available block types, and when you choose one, it will become that block type. (Placeholder blocks will reappear if a block is deleted, as well.)

If a Matrix field has both Min Blocks and Max blocks set to identical values, then the Add Block buttons should never be shown.

@dotmeta
Copy link

dotmeta commented Jul 12, 2017

Would love this feature as well.

@Laslo89
Copy link

Laslo89 commented Jan 23, 2018

Are there any updates on this feature. I would love to have it. I run into this need quiet frequently.

@brandonkelly
Copy link
Member

brandonkelly commented Jan 23, 2018

Just added it for Craft 3, albeit without my "placeholder blocks" idea.

Unfortunately I couldn’t add it for Craft 2, because in Craft 2, custom field validation only gets triggered if the field value is not empty. Assumption being that if you don’t want an empty value, you will mark the field as required, which is a fair assumption in most cases, but not if the field happens to have a “Min Blocks” setting, which should effectively make the field required everywhere it’s used.

@davidhellmann
Copy link
Contributor

davidhellmann commented Jan 24, 2018

@brandonkelly

To improve the AX, Matrix fields with less than the minimum should get placeholder blocks instead of the Add Block buttons. Placeholder blocks just show a list of the available block types, and when you choose one, it will become that block type. (Placeholder blocks will reappear if a block is deleted, as well.)

If a Matrix field has both Min Blocks and Max blocks set to identical values, then the Add Block buttons should never be shown.

This feature is not implemented right now?
When I set min and max to 1 it would be soooooooooooooooo nice to show the Fields instantly.

Turn this:
image

into this please :)
image

@brandonkelly
Copy link
Member

@davidhellmann I suppose we could do that if there’s only one block type.

@brandonkelly
Copy link
Member

And done: 2c2ea355

Also: 86d4dbe4

@davidhellmann
Copy link
Contributor

@brandonkelly
Nice try :P
Now just to fix the min max 1 bug on existing Fields :D

@narration-sd
Copy link
Contributor

narration-sd commented Jan 25, 2018

@davidhellmann: shake of head here, about your approach.

Brandon & co, and the community here, do and deserve better, no?

As far as your details, have a look and see how many cases and persons he's completed today. Maybe you just needed to be more clear in description, so it will be more likely to get it all the first time?

@davidhellmann
Copy link
Contributor

@narration-sd don't know what you mean and my last commend was a bit l fun.
The update from yesterday has an Bug when I set Min Block to 1 and Max Blocks to 1.
When I change that for existing Matrix Fields > The Matrix Field is completely empty.

@brandonkelly
Copy link
Member

lol, no worries @davidhellmann ! @lukeyouell created a dedicated issue for this too (#2353), and it's fixed for the next release. (FFR please create new issues for new bugs 🙏 thanks!)

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

No branches or pull requests

6 participants