简体   繁体   中英

How to remove only the update button on sonata admin edit?

I need to remove only the edit button ( Atualizar ) on the edit of a Sonata Admin:

<button type="submit" class="btn btn-success" name="btn_update_and_edit"><i class="fa fa-save" 
aria-hidden="true"></i> Atualizar</button>

But I need to keep the update and list ( Atualizar e sair ) option:

<button type="submit" class="btn btn-success" name="btn_update_and_list"><i class="fa fa-save"
></i> <i class="fa fa-list" aria-hidden="true"></i> Atualizar e sair</button>

I could probably remove it with JavaScript by subscribing the template, but it does not seen to be the best approach.

sdit表格上的选项

If you need hide this "Update" button for all edit pages then, a solution would be override the base_edit_form.html.twig template and its sonata_form_actions block, which contains this part.

Make sure to create a new template with the same name of the origin template file in this path:

- app/
  - Resources/
    - SonataAdminBundle/
      - views/
        - CRUD/
            base_edit_form.html.twig 

and overrides this block with the needed changes:

{% use '@SonataAdmin/CRUD/base_edit_form.html.twig' %}

{% block sonata_form_actions %} 
    ...
{% endblock %}

Note: Use formactions block name for oldest version if sonata_form_actions is not defined.

More about "How to Override Templates from Third-Party Bundles" here .

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