Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

How can i add anchor link in form label?

Solved by Chris Jung View solution

Started by lrnzt 9 years ago · 14 replies · 8030 views
9 years ago

I'm trying to add this way:

YAML
    - name: agree_to_terms
      label: Li e aceito o [termo](http://filelink.com) de prestação de serviços educacionais.
      type: checkbox
      validate:
        required: true

but it does not work :/

9 years ago

Try html, not markdown

YAML
    - name: agree_to_terms
       label: Li e aceito o <a href="http://filelink.com">termo</a> de prestação de serviços educacionais.
       type: checkbox
       validate:
         required: true
9 years ago

Hi, I'm trying to achieve the same thing but the HTML is not processed... Is there anything else I'm missing?

9 years ago

I guess you have to add ' ' since then it will be converted to a string.

YAML
    - name: agree_to_terms
   label: 'Li e aceito o <a href="http://filelink.com">termo</a> de prestação de serviços educacionais.'
   type: checkbox
   validate:
     required: true
9 years ago

Thanks for your reply. Yes, I've done that, still no luck...

9 years ago

Very strange... It works for me. How does the output look? And can you show me the TWIG code that outputs this?

9 years ago

I'm sure I'm missing something. I copy-pasted

YAML
- name: agree_to_terms
   label: 'Li e aceito o <a href="http://filelink.com">termo</a> de prestação de serviços educacionais.'
   type: checkbox
   validate:
     required: true

after fields

but all it displays is a checkbox and Li e aceito o <a href="http://filelink.com">termo</a> de prestação de serviços educacionais. (i.e. no link)

I haven't used any TWIG - should I?

9 years ago

Maybe you need to overwrite user/plugins/form/templates/forms/fields/checkbox/checkbox.html.twig in your child theme. There is an escaping for the field labels.

9 years ago

I think I know why. When you use label it is in a html tag that can not process html. If you can copy the html source of the form so I can see what tags the form is using then I can find it in the form plugin and make a work around for you.

👍 1
9 years ago Solution

Maybe changing {{ field.label|t|e }} to {{ field.label|t }} helps.

👍 1
9 years ago

Oh yeah, this sorted it!!! Thanks for both of your input.

9 years ago

Nice, it worked out! And yeah e option disable HTML processing.

Please mark @chris_jung replay as an answer 🙂

9 years ago

I'm not sure I can mark it as an answer because it wasn't me who started the topic...

9 years ago

You are right...

Then @lrnzt please mark @chris_jung reply as an answer 🙂

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1138 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 62 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 136 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 130 7 months ago