Allow custom markup to be set per instance#299
Allow custom markup to be set per instance#299Toutouwai wants to merge 1 commit intoprocesswire:devfrom
Conversation
|
@Toutouwai Wouldn't this only affect the markup from that one instance of InputfieldWrapper? Forms usually have multiple InputfieldWrappers in them, which is why this is stored statically and set with Are there cases where you'd be rendering multiple forms using different wrapper markup in the same request? I've not come across that yet. But I suppose you could do it this way: That whole thing could potentially be abstracted behind the |
Yes, that's exactly the aim of the pull request. For me this request is about the ability to customise specific parts of the admin markup via hooks without affecting other InputfieldWrappers. As an example, I wanted to add some markup adjacent to (not within) the With the changes in this pull request I can do this: $wire->addHookBefore('InputfieldWrapper(name^=repeater_form_)::render', function(HookEvent $event) {
$wrapper = $event->object;
$markup = [
'item_label' => "<label class='InputfieldHeader ui-widget-header{class}' for='{for}'>{out}</label><div class='my-extra-mark'>My extra markup here</div>",
];
$wrapper->setInstanceMarkup($markup);
});To achieve these targeted changes it's not sufficient to set the static $markup property before the form render and reset it after the form render because all the InputfieldWrappers within each repeater item will be affected before $markup can be reset. |

Related forum post: https://processwire.com/talk/topic/30194-weekly-update-%E2%80%93%C2%A011-july-2024/?do=findComment&comment=242758