theruss

OK, Ima going to see how to do what you need. I'm curious now... P-P

Jay

Guys can you use a thread please?

theruss

Granted...that's both server side and client side changes required...

theruss

Using that syntax, you can take the CheckboxsetField (which extends FormField) and pass a custom path to the overridden template rather than relying on SilverStripe's built-in logic

theruss

Case in point: FormField::setTemplate()

theruss

If you absolutely need to. My point here is that if there's way to do it programmatically within an Extension class for example, then that's more maintainable that overriding a default template that may break in subsequent versions of the CMS' UI

Barry

but overriding a template for use in the CMS should be straightforward?

Barry

but i dont think i can have 3 separate fields - since they are all saving to the same many-many relation

theruss

OK, I'll try to see how to do what you need. I'm curious now....

Barry

so i tried this:

  1. $field = CheckboxSetField::create();
  2. $field->setTemplate('MyApp\Forms\GroupedCheckboxSetField');
Barry

does setting the template need to be a static method?

theruss

No, you can tell by the camel-case naming (Or just inspecting FormField.php)

Barry

still renders default template in the CMS context

Barry

i can see the template is the first one in $field->getTemplates()

Barry

but the $field->ThemeDir() is set to /resources/silverstripe/admin/themes/cms-forms

Barry

which does not have my custom template

Barry

since my template is in themes\mytheme\....

Barry

this seems to have an effect:

  1. SSViewer::add_themes([
  2. 'mytheme'
  3. ]);
Barry

i can now extend the regular field, and the cms will use my custom template

Barry

maybe its so that public facing form templates dont mess up the CMS

theruss

But just came to the conclusion that http://CheckboxSetField.ss isn't actualy the template being used where I think it is

Barry

yeah - that does not mention anything about the theme separation

theruss

I recall having to programmatically add themes on an ad-hoc basis before like you've done.

Barry

thanks for helping me think it through! appreciated 🙂


Show less replies