Custom field type like Phone

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnapriya
    Senior Member
    • Aug 2017
    • 209

    Custom field type like Phone

    Hi,

    I am trying to create new field type like phone / email(multiple add option).

    Do we need to create the relationship table like entity_phone_number at the backend or it is automatically generated with the code?

    If automatic, where can I find the code to create table?

    Please help.

    Thanks.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello

    application/Espo/Core/Utils/Database/Orm/Fields/Email.php

    Comment

    • krishnapriya
      Senior Member
      • Aug 2017
      • 209

      #3
      Hi,

      I got the realtion table o rebuild.

      Field is visible on create but failed to save values to db.

      Giving error => Column not found: 1054 Unknown column 'relationName.name' in 'field list'

      Comment

      • krishnapriya
        Senior Member
        • Aug 2017
        • 209

        #4
        Hi,

        I copied the same way as application/Espo/Core/Utils/Database/Orm/Fields/Email.php and application/Espo/Core/Utils/Database/Orm/Fields/Phone.php

        I that relation emailAddresses need to define in any other files other than application/Espo/Core/Utils/Database/Orm/Fields/Email.php

        Confused. Please help.

        Thanks.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          application/Espo/Repositories/EmailAddress.php storeEntityEmailAddress
          and check where does it call

          Comment

          • krishnapriya
            Senior Member
            • Aug 2017
            • 209

            #6
            Hi,

            Tried to create 2 functions=>

            1. handleListItemParams($params)() in handleSelectParams()

            2. processListItemSave(Entity $entity) () in afterSave() of RDB for the new field type

            Both gives bad server response.
            No call reaches storeEntityListItem

            Please help.

            Comment

            • krishnapriya
              Senior Member
              • Aug 2017
              • 209

              #7
              Hi,

              It is working now.

              Error was I tried to create them with "notCreatable": false so that they became available in entity manager fields, but giving error on save.
              Any way is there to make phone or email field creatable from the entity manager?

              Please help.
              Thanks.

              Comment

              • tanya
                Senior Member
                • Jun 2014
                • 4308

                #8
                notCreatable ?
                this parameter is used only on client side (client/src/views/admin/field-manager/list.js)
                if you want don't create a column, you need to use notStorable

                Comment

                • krishnapriya
                  Senior Member
                  • Aug 2017
                  • 209

                  #9
                  Hello,
                  What I mean is how can I add phone to Add Field drop down of entity manager? Is that possible?
                  This was what I tried.
                  Click image for larger version

Name:	add field.png
Views:	952
Size:	33.7 KB
ID:	31998

                  Comment

                  • tanya
                    Senior Member
                    • Jun 2014
                    • 4308

                    #10
                    This field is better to add manually. To make field type visible, set "notCreatable": true.
                    Don't remember the reason, why these fields were hide, but I'm sure, the reason exists. Better don't make these fields visible in the list

                    Comment

                    • krishnapriya
                      Senior Member
                      • Aug 2017
                      • 209

                      #11
                      Yes Tanya that worked.

                      Comment

                      • krishnapriya
                        Senior Member
                        • Aug 2017
                        • 209

                        #12
                        But we have to use same name phoneNumber for the field, otherwise it will save only first value in the list.

                        Comment

                        • krishnapriya
                          Senior Member
                          • Aug 2017
                          • 209

                          #13
                          Hi,
                          Can we set name of a field automatically by program ?
                          Click image for larger version

Name:	name of field.png
Views:	834
Size:	16.6 KB
ID:	32016

                          Comment

                          • tanya
                            Senior Member
                            • Jun 2014
                            • 4308

                            #14
                            client/src/views/admin/field-manager/edit.js
                            search populateDefaults
                            you can set the name in this area

                            Comment

                            • krishnapriya
                              Senior Member
                              • Aug 2017
                              • 209

                              #15
                              Thanks tanya. That worked.

                              Comment

                              Working...