Jump to content

The matrix....again


Recommended Posts

Posting here instead of going via the potential support black hole 😄

I've made use of a manageable matrix a number of times now, and each time I do there is something else about it that ends up winding me up 😄

Attaching a sample plugin with settings that use a manageable matrix - notice the Yes/No field? I reported this a while back (in 4.2.x, I think) and it did get fixed if I remember correctly. Also....the color picker doesn't work on a newly added line.

All of these items work brilliantly on an already defined unmanageable matrix, but going manageable and you've got these issues - the Yes/No can be overcome by using a checkbox or a select field instead, but the color one requires a save/edit of the settings.

The matrix.xml

Link to comment
Share on other sites

  • 3 weeks later...

So I finally got around to looking into this. The color picker issue is a genuine bug which we'll look to resolve, but the YesNo field issue is largely due to how you're generating the matrix rows. Instead of providing a closure that returns the field with a static name, you should use this methodology instead with a manageable matrix:

$matrix->columns = array(
    ...
    'yesno' => array( 'YesNo' ),
    'color' => array( 'Color' ),
);

This allows the field names to get set specially. Alternatively, instead of

    'yesno' => function($key, $value, $data) {
        return new \IPS\Helpers\Form\YesNo('meh', $value);
    },

you can use

    'yesno' => function($key, $value, $data) {
        return new \IPS\Helpers\Form\YesNo($key, $value);
    },

But ultimately by providing a static field name, you end up with multiple fields duplicating the same ID which causes the YesNo field issues. IOW - that part isn't a bug, it's an issue with how you are generating the fields in this case.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...