How can i add anchor link in form label?


#1

I’m trying to add this way:

    - 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 :confused:


Markdown in form label to add page link
Add link to a checkbox field's label
#2

Try html, not markdown

    - 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

#3

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


#4

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

    - 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

#5

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


#6

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


#7

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

- 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?


#8

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.


Add link to a checkbox field's label
#9

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.


#10

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


#11

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


#12

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

Please mark @chris_jung replay as an answer :slight_smile:


#13

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


#14

You are right…

Then @lrnzt please mark @chris_jung reply as an answer :slight_smile:


#15

You can easily add an anchor link in the form of a label which is very easy like adding a hyperlink. You may sometimes face gmail server error 007 which can be easily fixed.