简体   繁体   English

Sonata Admin-在过滤器中添加帮助消息

[英]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.. 我也尝试过sonata_help选项,但是它不起作用。

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. 如果您不想覆盖模板,则可以使用基本的jQuery在加载页面上向过滤器添加属性。 (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. 它很快速而且不是很干净,但是它很有效而且很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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