Easyadminbundle: Add "url", "label" as options for url type field (list/show)

Created on 14 Apr 2019  Â·  7Comments  Â·  Source: EasyCorp/EasyAdminBundle

Short description of what this feature will allow to do:

  • I want to use the url field in the type view, to display a link to the show view.
  • I want to display a label instead the URL

Example of how to use this feature

- { property: name, type: url, type_options: { url: "/admin/?entity=offer&action=show&menuIndex=1&submenuIndex=-1&id=%%entity_id%%" } }
- { property: google_profile, type: url, type_options: { label: "Google Profile"  } }

Maybe something like:

{% set url = field_options.type_options.url|default(value) %}
{% set label = field_options.type_options.label|default(value) %}

{% set url = url|replace({'%entity_id%' : item.id}) %}

{% if view == 'show' %}
    <a target="_blank" href="{{ url }}">{{ label }}</a>
{% else %}
    <a target="_blank" href="{{ url }}">{{ label|replace({ 'https://': '', 'http://': '' })|easyadmin_truncate }}</a>
{% endif %}
feature wontfix

Most helpful comment

As explained in #2721, it was decided to not include this feature by default, so we're closing this issue as "won't fix". Luckily, it's possible to implement this feature as explained in the previous comments. Thanks.

All 7 comments

I think it is a matter of writing proper FormType, and it's not related with EasyAdmin.

Ho can we use FormType inside a list view?

Yeah, my bad. I understood it incorrectly. Still, it should be done separately, without modifying EasyAdmin. One time I have done this with template configuration.

Config:

easy_admin:
  entities:
    User:
      list:
        fields:
        - property: website
          template: "path/to/field_link.html.twig"

field_link.html.twig

<a href="{{ value }}" data-tooltip="on" title="{{ value }}" target="_blank">
    <i class="fa fa-link"></i>
</a>

You are right ! this is possible and it works.

Le dim. 14 avr. 2019 à 17:11, Krzysztof Trzos notifications@github.com a
écrit :

Yeah, my bad. I understood it incorrectly. Still, it should be done
separately, without modifying EasyAdmin. One time I have done this with
template configuration.

Config:

easy_admin:
entities:
User:
list:
fields:
- property: website
template: "/display/field_link.html.twig"

field_link.html.twig



—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/EasyCorp/EasyAdminBundle/issues/2695#issuecomment-482995657,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABKc6XzCfKFGKw9TjTwO8Kv_jhSiIinSks5vg0UTgaJpZM4cufNt
.

I've created PR (#2721) which will add posibility to define "label" type option for "url" field type.

As explained in #2721, it was decided to not include this feature by default, so we're closing this issue as "won't fix". Luckily, it's possible to implement this feature as explained in the previous comments. Thanks.

You are right, better to keep this bundle simple and extensible by code, I like this logic!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BigMichi1 picture BigMichi1  Â·  3Comments

devkbsc picture devkbsc  Â·  3Comments

haithem-rihane picture haithem-rihane  Â·  4Comments

cve picture cve  Â·  4Comments

nickicool picture nickicool  Â·  4Comments