3

Is it possible to have all Matrix rows in the Control Panel entry be in the collapsed state by default?

Thanks. Lori

7

Inject this piece of JS in your CP and they will always be closed by default:

$('.matrixblock').each(function() {
    $(this).addClass('collapsed');
    Craft.MatrixInput.rememberCollapsedBlockId($(this).data('id'));
});

Here's an example plugin that will inject it in the CP: https://gist.github.com/boboldehampsink/6bb9e5296977a99c39b1

| improve this answer | |
  • Great to hear! What file do I add that code into? – Lori Jun 18 '15 at 15:22
  • 1
    Its best to create a new plugin for it and make the init() function include the js. I've created a gist that should set you up: gist.github.com/boboldehampsink/6bb9e5296977a99c39b1 – Bob Olde Hampsink Jun 18 '15 at 16:57
  • 2
    Or you could just use CP JS ;) – Lindsey D Jun 18 '15 at 20:44
  • I can't get this working with CP JS in Craft 2 — the class is being appended but the field is still open... looks like the style needs to be changed too? [EDIT: maybe it's because the matrix field is inside a Supertable?] – James Greig Apr 20 '18 at 16:17
  • This would be handy to have just as a setting in the fieldtype. – Andy Sep 17 '18 at 14:32
2

Not that I'm aware of, but this feature request and response may at least help a bit. http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7425151--expand-collapse-all-ui-for-matrix-fields

| improve this answer | |
  • While its true that this doesn't come out of the box, it easily can be done. – Bob Olde Hampsink Jun 18 '15 at 17:46

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.