Jump to content

HTML tag in custom Repeater label


Nicolas
 Share

Recommended Posts

Is there a way to display/allow HTML tags in custom repeater label ?

// CHange the label of the grape variety repeater
$this->addHookAfter('InputfieldRepeater::renderRepeaterLabel', function(HookEvent $event) {
    $repeater = $event->object;

    if($repeater->name === 'grape_varieties') {
        $option_page = $event->arguments(2);
        $event->return = $option_page->title . '<span>(' . $option_page->color . ')</span>';
    }
});

Using the code above the span tag is escaped and not interpreted in the label.

Link to comment
Share on other sites

To do this I think you'll have to hook the rendering of the repeater item, which is a fieldset:

$wire->addHookBefore('InputfieldFieldset(name^=repeater_item)::render', function(HookEvent $event) {
	$inputfield = $event->object;
	$inputfield->label = $event->wire()->sanitizer->unentities($inputfield->label);
});

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...