How to correctly extend structure field?

Hi there,

I am currently struggling with my intent to extend the structure field within my own field plugin? I built a simple plugin called “Module” to use the StructureField within site/fields/module/module.php.

<?php

class ModuleField extends StructureField {

}

I would expect that it uses the base class StructureField and behaves like normal, but it throws an exception “Invalid field”.

Is there anything I do oversee?

Thank you very much,

Chris

1 Like

So, it’s solved. Had some misunderstanding and finally got it to work.

Could you please post some information what the issue was and how you fixed it? Might be helpful for other users. :slight_smile:

I just encountered this problem too. May I ask how you did solve this?

I also get this error when editing an extended structure field.
If anyone have much time over and like to dig into this, I think it could help others.

I made some findings about this. I looked in to my snippetfield to find out. I’ve not tested anything but I’m quite sure I’m right.

In the function headline() it says:

$add->attr('href', purl($this->model, 'field/' . $this->name . '/snippetfield/add'));

So for some reason I’ve changed the add url with snippetfield instead of structurefield. That’s because we don’t want to use the route of the structure field.

If we look a bit more there is a function called routes() within the field and it goes magically to the name of the field, in this case snippetfield.

I’ll update this post if I’ll find more.

I ran into this issue as well and unable to fix it. How did you fix the error? Thanks.