processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Repeater template with multilanguage fields does not take in account the noLang setting in the parent template.

Open kixe opened this issue 7 months ago • 3 comments

If a template is set to noLang=1, I would expect inheritance for repeater fields. Currently multilanguage fields within a repeater remain multilanguage even though the parent template is set to noLang=1.

Of course, it would be best to provide an option to set noLang individually in the field settings of the repeater field in context of the template where the repeater lives in.

kixe avatar May 23 '25 07:05 kixe

@kixe Repeaters have their own templates, so you'd probably have to set the noLang for the template used by your repeater. It would make sense that it gets inherited though, so I can look into seeing what might be possible there.

ryancramerdesign avatar Jul 01 '25 14:07 ryancramerdesign

Hi @ryancramerdesign , I am having the same issue when using the module Restrict Multi-Language Branch.

The module assumes that the Processwire Core will take care of the delegation of the noLang=1 set on the Template to all fields including the Repeaters and FieldsetPage (all the fields that extend the FieldtypeRepeater).

This is the code on the "Restrict Multi-Language Branch" module that assumes this:

public function multilanguageStatusCheck(HookEvent $event) {

        $p = $event->object->getPage();

        // if actual noLang setting for this page's template is set to disabled (1) then exit now so we don't potentially enable
        if($p->template->noLang === 1) return;

        
        // ...

}

Just to make it work for Repeaters and FieldsetPage (all the fields that extend the FieldtypeRepeater) I did the folowing patch to the module:

public function multilanguageStatusCheck(HookEvent $event) {

        $p = $event->object->getPage();

        // PATCH
        // if actual noLang setting for this page's template is set to disabled (1) then exit now so we don't potentially enable
        if($p->template->noLang === 1) {
            foreach($p->fields as $f) {
                if($f->type instanceof FieldtypeRepeater === false) continue;
                $this->wire('templates')->get(FieldtypeRepeater::templateNamePrefix . $f->name)->noLang = '1';
            }
            return;
        }

        
        // ...

}

The question is:

  • Is this the best and only way to do it at this moment?

Nonetheless, because the "Disable multi-language support for this template?" is a Processwire Core's feature I think it would be great if the noLang=1 set on the template would be inherited by all the fields that have their own template.

So, only for testing I did the following temporary changes/patches to the:

  • wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeFieldsetPage.module
  • wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module

The following changes/patches are raw implementations and were only for testing purposes:

  • On the wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeFieldsetPage.module:
public function getFieldsetPage(Page $page, Field $field, $createIfNotExists = true){
    
    // ...

    if($readyPage instanceof FieldsetPage) {
        $readyPage->setForPage($page);
        $readyPage->setForField($field);
        $readyPage->setTrackChanges(true);

        // PATCH
        // inherit noLang from template of the page being edited
        if($page->template->noLang === 1) {
            $readyPage->template->noLang = '1';
        }
    }

    return $readyPage;

}
  • On the wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module:
public function getInputfield(Page $page, Field $field) {

        // PATCH
        // inherit noLang from template of the page being edited
        if($page->template->noLang === 1) {
            wire('templates')->get($field->template_id)->noLang = '1';
        }

        // ...

}

Like I said, this is just a raw implementation of the changes/patches and it might be necessary to do other changes. Can you please test and verify this and give your feedback if possible to implement the changes in the Processwire Core.

Sorry for the long comment and thank you for your time.

Kind regards

bluellyr avatar Oct 09 '25 12:10 bluellyr

@ryancramerdesign - just to throw in my two cents. I really do think that repeaters should inherit the setting from the template of the page they are on. Obviously repeaters have their own template, but as far as the GUI goes, a repeater is just a field like any other and should respect that noLang setting in the same way. And I can't see why you wouldn't want repeater fields to not use the parent page template's noLang setting.

adrianbj avatar Oct 09 '25 12:10 adrianbj