7

Just started working with Craft, and it's been great! One question I have is regarding the 'correct' way to create a group of fields, rather than using Matrix or Table.

To better illustrate, see the below screenshot of a Matrix, which is setup as a Global for people to add their contact information.

enter image description here

Obviously, it's not really being used for the purpose of repeating content, but at least it groups fields together nicely. It does have the greyed-out button when setting Max Blocks to 1.

The other alternative would be to create each Field separately for the 3 fields above, and add those to the Field Layout. This is kind of a fair amount of work, and leaves you with a massive cluster of Fields (I'm aware you can Group them).

Anyway - hope I've explained myself! Just wanted to bounce ideas around, and at least make sure I'm on the right track!

  • If your "max blocks" is set to 1, aren't you better off just creating those as individual fields (instead of a Matrix)? Using a Matrix field creates a separate table in the database, and therefore more complex SQL calls... With only one instance of each field, I don't see the value of running that through a Matrix field. – Lindsey D Aug 6 '14 at 18:04
  • He's not deliberately doing it as a matrix field, the question is related to how to make it clear to the user that some fields are grouped to improve usability. At the moment, there's no clear way to group fields for the client, apart from tabs. – darylknight Feb 2 '15 at 11:44
3

Depending on the amount of data required (and if it makes logical sense to have the data separate from the entry) I'd probably set this up as a "Contact details" section itself, using the individual matrix fields from your example.

Then if some other entry type needs it, set up an entries field in that entry type, limited to entries in the "contact details" section and limited to the number of contact detail entries you want to show, probably 1 going by your example.

This way you can still have your details grouped (as a separate entry) but it's more compact as a single field rather than a matrix in the fields of the entry you're using the contact details in.

The trade-off is that you need to enter your contact details entry before you try to add it to your "x" entry field.

If it makes no logical sense to have the fields as entirely different sections and your fields are getting cumbersome I think the best way is to put them in a different tab to at least remove the clutter.

  • +1 If the fields seem cluttered, give them their own tab in the field layout. – Lindsey D Aug 6 '14 at 18:06
3

As other answers here say, unfortunately creating tabs is currently the only way to "group" contextually related fields (or create "fieldsets", as it were).

What you could do, is use either FieldNotes or Entry Instructions to create messages/headers in your edit tab, visually separating one "group" of fields from another.

2

Just in case anyone is interested, I've decided to make a plugin for this. It's pretty basic, but its exactly what I was after. It's essentially a regular Table with a Label option to provide some read-only text.

https://github.com/engram-design/SetTable

0

Using tabs is the only way to do this at the moment. As Lindsey says, using a Matrix field adds a table to the database and will slow down your load times.

I'd prefer, like you, to be able to group fields to improve usability for the client, but there's no way to do this at the moment apart from tabs.

  • thats right, its not a technical issue at all (works just fine), but rather a visual issue. At the moment, I've just created custom fieldtypes for this sort of thing, but would be great if there was a high-level, or provided by a plugin way to group fields a little. I'm using github.com/elivz/VzAddress-Craft which is pretty close to how I'd like to be able to show some fields. Cheers! – crawf Feb 2 '15 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.