{% if admin.hasAccess('edit', object) and admin.hasRoute('edit') and not object.mandatory %}
    <a href="{{ admin.generateObjectUrl('edit', object) }}" class="btn btn-sm btn-default edit_link" title="{{ 'action_edit'|trans({}, 'SonataAdminBundle') }}">
        <i class="fa fa-pencil" aria-hidden="true"></i>
        {{ 'action_edit'|trans({}, 'SonataAdminBundle') }}
    </a>
{% endif %}