简体   繁体   中英

Sonata Admin - adding help message in filters

I want to add a help message in the filters form.

I'm able to do it in the edition form, like this:

<?php
public function configureFormFields(FormMapper $formMapper)
{
    $formMapper->add('name', null, array('help'=>'Help Message'));
}

but that doesn't work on the filters

<?php
public function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper->add('name', null, array('help'=>'Help Message'));
}

I've also tried the sonata_help option, but it doesn't work..

is there a way to add a help message in the filters form (without making modifications on templates)?

If you don't want override templates, you can use basic jQuery for add attributes to your filters on load page. (create a script and add it to assets config)

Exemple :

jQuery(function(){
    $('#filter_someproperty_value').attr('help', 'Your help text');
});

It's quick and not very clean, but it works and it's simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM