dongzhi2332 2019-05-07 14:52
浏览 33

在某些条件下更改行不透明度

In a sonata admin project, using symfony 4, I would like to change the row opacity based on an entity field called visible, which is a boolean of course.

In other words, if the visible field is true, the opacity is going to be 1, else is going to be 0.2 or something like that.

I have done my research and I have found a couple of articles regarding the customization of the row templates, but none of those articles seems to be usefull to me. I know for a fact this is possible but I cant find the way to do it.

This is my list mapper.

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
      ->addIdentifier('title', null, [
        'label' => 'Titulo',
        'sortable' => false
      ])
      ->add('description', null, [
        'label' => 'Descripcion',
        'sortable' => false
      ])
      ->add('idAuthor.name', null, [
        'label' => 'Autor',
        'sortable' => false
      ])
      ->add('idCategory.name', null, [
        'label' => 'Categoria',
        'sortable' => false
      ])
      ->add('position', null, [
        'label' => 'Posicion',
        'sortable' => false
      ])
      ->add('visible', 'boolean', [
        'label' => 'Visible',
        'editable' => true
      ])
      ->add('_action', null, [
        'label' => 'Ordenar posicion',
        'actions' => [
          'move' => [
            'template' => '@PixSortableBehavior/Default    /_sort_drag_drop.html.twig',
            'enable_top_bottom_buttons' => false
          ],
        ],
      ]);
  }

As you can see there is my visible field, which can be edited on the page, i would like to change that row opacity depending on that variable

This is the html twig file where I think I have to code my logic, base_list_inner_row.html.twig file

{% for field_description in admin.list.elements %}
    {% if field_description.name == '_action' and     app.request.isXmlHttpRequest %}
        {# Action buttons disabled in ajax view! #}
    {% elseif field_description.getOption('ajax_hidden') == true and     app.request.isXmlHttpRequest %}
    {% else %}
        {{ object|render_list_element(field_description) }}
    {% endif %}
{% endfor %}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波
    • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
    • ¥15 钢筋实图交点识别,机器视觉代码
    • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
    • ¥50 400g qsfp 光模块iphy方案
    • ¥15 两块ADC0804用proteus仿真时,出现异常
    • ¥15 关于风控系统,如何去选择