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

Inputfields Javascript API: focus() and find() do not work for Repeater field in tab

Open Toutouwai opened this issue 4 years ago • 0 comments

Short description of the issue

If you have a Repeater field in a FieldsetTab, the focus() and find() functions of the Inputfields Javascript API do not work for the field.

I have a Text field (for comparison) and a Repeater field inside a FieldsetTab:

2021-11-06_141359

I have the following hook to add links and JS to focus the inputfields (the find function has the same problem):

$wire->addHookAfter('ProcessPageEdit::buildFormContent', function (HookEvent $event) {
    /* @var InputfieldWrapper $wrapper */
    $wrapper = $event->return;
    /** @var InputfieldMarkup $f */
    $f = $event->wire()->modules->get('InputfieldMarkup');
    $f->label = 'Links';
    $f->value = <<<EOT
<p>These are links to the <a data-focus='text_1' href='#'>Text 1</a> field and the <a data-focus='test_repeater' href='#'>Test Repeater</a> field</p>
<script >
$(document).ready(function() {
    $('a[data-focus]').click(function() {
        Inputfields.focus($(this).data('focus'));
    });
});
</script>
EOT;
    $wrapper->add($f);
});

Screencast:

focus

Setup/Environment

  • ProcessWire version: 3.0.189

Toutouwai avatar Nov 06 '21 01:11 Toutouwai