Jump to content

Automate Repeater Matrix types creation with RockMigrations


Ivan Gretsky
 Share

Recommended Posts

3 minutes ago, nloyola said:

Today I updated RepeaterMatrix to version 0.1.1, but I still get the error when creating the repeater matrix. Using createRepeaterMatrixField() returns a Field instance and not RepeaterMatrixField.

Does anyone know how to fix this?

Thank you

I'll try to replicate this. What versions of ProcessWire and RockMigrations are you on?

Link to comment
Share on other sites

  • 1 month later...

Hey @gebeer remember this code that we added in our DMs?


      // this will auto-generate the repeater matrix template
      if ($field->type instanceof FieldtypeRepeaterMatrix) {
        $field->type->getMatrixTemplate($field);
      } elseif ($field->type instanceof FieldtypeRepeater) {
        $field->type->getRepeaterTemplate($field);
      }

It didn't make it into the final PR I don't think.

We inserted this at the end of createField. The original (and currently live version) only works for returning a FieldtypeRepeater I think.

https://github.com/baumrock/RockMigrations/blob/be40ee6ae51a9f9f3ab9a9622d3acc12e069df5e/RockMigrations.module.php#L1092

  • Like 1
Link to comment
Share on other sites

On 2/3/2024 at 3:38 AM, gornycreative said:

Hey @gebeer remember this code that we added in our DMs?


      // this will auto-generate the repeater matrix template
      if ($field->type instanceof FieldtypeRepeaterMatrix) {
        $field->type->getMatrixTemplate($field);
      } elseif ($field->type instanceof FieldtypeRepeater) {
        $field->type->getRepeaterTemplate($field);
      }

It didn't make it into the final PR I don't think.

We inserted this at the end of createField. The original (and currently live version) only works for returning a FieldtypeRepeater I think.

https://github.com/baumrock/RockMigrations/blob/be40ee6ae51a9f9f3ab9a9622d3acc12e069df5e/RockMigrations.module.php#L1092

Thanks for spotting this. Did you try this and will it return the correct field type? If so, could you please make a PR? Thank you.

  • Like 1
Link to comment
Share on other sites

9 hours ago, gornycreative said:

I'm not sure. The only time I get a Field returned sometimes is if I run a setMatrixItems call from ready.php and I'll get a Field::setMatrixItems does not exist or is not callable in this context error.

I see. This problem is quite hard to debug because it is not 100% reproducable. For me it is happening only sporadicly and I didn't see it in quite a while now. Would you like to try and put that missing snippet in the createField method and see if the problem goas away?

Link to comment
Share on other sites

On 2/8/2024 at 8:10 AM, gornycreative said:

I will add it to the pile for more testing. I don't see the original problem stated in the question, just my weird related one? And I have been running the snippet in createField from our first discussion - so quite some time now.

Thanks a lot for your help with testing. I also added the snippet and will have an eye on this for a while.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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