Callback / Filter for MB Group Title?

Support MB Group Callback / Filter for MB Group Title?Resolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #44889
    BomesBomes
    Participant

    I have timestamps as subfields of my cloneable group and would like to customize the group title is it possible to use some callback or filter on this? At the moment I am using 'group_title' => '{startdate} - {enddate}' which displays the original timestamps and is not very convenient for end users.

    #44899
    PeterPeter
    Moderator

    Hello Bomes,

    There isn't a filter hook to change the group title. The subfield value in the group title will display the original that is saved to the database.

    #44902
    BomesBomes
    Participant

    Got that, thank you.

    Any hint for good approach to format those group_title? I looked through the code a bit and it seems the group_title is only built within js on the frontend, is it?

    I was just playing around with the hooks/filters for default / meta calls and didnt come to a reasonable approach. Also I was thinking about creating a helper field and wondered if I could dynamically create default values. sanitize hooks are only called upon save not on changes within the form, are they?

    #44915
    PeterPeter
    Moderator

    Hello,

    I will inform the development team to consider supporting a filter hook to customize the group title in future updates.

    Thank you.

    #45228
    BomesBomes
    Participant

    I have finally found a solution that worked for me:

    
    // upon start
    $('#kurstermine .rwmb-clone').each(function() {
        $(row).find('h4.rwmb-group-title').text('my caption')M
    });
    
    // whenever setting is changed
    $('#kurstermine').on('change', 'input.rwmb-date', function() {
        $(row).find('h4.rwmb-group-title').text('my caption')M
    })
    #46890
    Anh TranAnh Tran
    Keymaster

    Hi Bomes,

    The hook for group title will be added in the next version of Group. Once it's done, you can use the filter like this:

    jQuery( function() {
        // Change "myVendor/myPlugin" to your unique namespace
        rwmb.hooks.addFilter( 'group.title', 'myVendor/myPlugin', function( title ) {
            // Change the title and return the value here.
            return title + ' Some random string';
        } );
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.