add dynamicly a css atribute in a Hook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Olga
    Junior Member
    • Sep 2017
    • 9

    add dynamicly a css atribute in a Hook

    Hi,
    i want do display the names of contacts which have a bolean variable set to true in grey color. Is this possible to do in a Hook? Basicly i want to check in a afterSave Hook if this value is true and if so i want to add a CSS atribute or a CSS class. Or is it possible to use jquery in a hook?
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    Don't recommend you to set css on backend.
    Better to add own view to the field name and do this in a field view. https://www.espocrm.com/documentatio...nt-field-views
    and for setting the color of field is better don't set it in css, but just add / remove a bootstrap class

    Comment

    • Olga
      Junior Member
      • Sep 2017
      • 9

      #3
      Thank you very much. I will look into it.

      Comment

      • Olga
        Junior Member
        • Sep 2017
        • 9

        #4
        Hallo tanya,
        i don't know how i can get this to work. In custom/Espo/Custom/Resources/metadata/entityDefs/Contact.json i added:
        "fields": {
        "name": { "view":"custom:views/contact/fields/name" } } and in client/src/views/contact/fields/ i added a file called name.js but i get a error message: Uncaught Error: Could not load file 'client/custom/src/views/contact/fields/name.js is something missing?

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          you need to add your file in path you see in log
          client/custom/src/views/contact/fields/name.js
          custom namespace (custom: ) is located in client/custom/
          src/ for js, res/ for tmp

          Comment

          • Olga
            Junior Member
            • Sep 2017
            • 9

            #6
            Hi,
            i have put it now in the right direction (i had a typo in path) but now i get this error:
            Uncaught RangeError: Maximum call stack size exceeded

            Comment

            • tanya
              Senior Member
              • Jun 2014
              • 4308

              #7
              attach the file

              Comment

              • Olga
                Junior Member
                • Sep 2017
                • 9

                #8

                I dont get this error anymore if i add ['views/fields/base']

                this file is a js file but im not allowed to upload js files so a made a txt
                Attached Files
                Last edited by Olga; 12-11-2017, 01:02 PM.

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #9
                  the name of contact is better to extend from 'views/fields/person-name', if I understand you well.
                  and the label element is better to get with this.getLabelElement()

                  Comment

                  Working...