Announcement

Collapse
No announcement yet.

Request for assistance with a PDF template.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request for assistance with a PDF template.

    Hello friends, Please, it's my first time using the PDF model for an employment contract. Could someone assist me in displaying a field based on a condition?

    For example, I have an enumeration list containing: Expenses included and Expenses not included, and two fields named 'expenses' and 'no_expenses'. In my template, I want to display only the field that I have selected in the list. For instance, if I select Expenses, then print the 'expenses' field in the template.

    I haven't quite understood the documentation, and there doesn't seem to be an example. Thank you.

  • #2
    Hello abidoss
    you have two options. You can use conditions or you can use PHP to build template helpers. It'll be better to prepare more advanced condition logic.
    You can use this conditions in PDF to check whether value is set or not, but as far as i remember, you can't use it to check WHICH value is set.

    {{#if value}}
    {{value}}
    {{else}}
    No value
    {{/if}}​

    Comment


    • #3
      try this, change the enumField with the name of the enum field

      PHP Code:
      {{#ifEqual enumField 'Expenses included'}}
          
      {{expenses}}
      {{else}}
          {{
      no_expenses}}
      {{/
      ifEqual}}​ 

      Comment


      • emillod
        emillod commented
        Editing a comment
        Thank you!

      • rabii
        rabii commented
        Editing a comment
        you are welcome mate

    • #4
      Something is off; it prints that with a question mark

      Attached Files

      Comment


      • #5
        i have just tested the code and it works, when you copy code from the form, it will add some weird character at the end of the code make sure you past code into code editor remove any extra characters and then past it to your instance.

        Comment


        • #6
          Use triple braces: https://docs.espocrm.com/user-guide/...df/#text-field

          Comment


          • #7
            Now, everything is working well. Thank you!

            Comment

            Working...
            X