No announcement yet.

Email Address and Phone Number value object field types

  • Filter
  • Time
  • Show
Clear All
new posts

  • Email Address and Phone Number value object field types

    I am little confused by the Value Objects explanations on this page:

    The example for Email Address and Phone Number value objects shows this:
    PHP Code:


    $primary $emailAddressGroup->getPrimary();

    $modifiedEmailAddressGroup $emailAddressGroup

    I have a custom entity ('MyEntity') with this in its entityDefs:
    PHP Code:
    "fields": {
    "phoneNumber": {
    "typeList": [
    "Dr. Office",
    "Event Location",
    "Site Contact"
    "customMask""(999) 999-9999"

    But I get an error if I try to this:
    PHP Code:
    $myEntity $entityManager->getEntityById('myEntity''id-string');
    $phoneNumberGroup $myEntity->getPhoneNumberGroup(); 
    Also, how do I add a phone number to a new record for this entity?

  • #2
    You need to define getEmailAddressGroup method in your entity class. Just copy it from another class where it exists.

    If you get any errors and seek help on the forum, it's reasonable to provide error details.


    • #3
      My apologies yuri.

      It is a function not found error as follows:

      PHP Code:
      Call to undefined method Espo\Core\Templates\Entities\BasePlus::getPhoneNumberGroup() 
      The following does work, however:

      PHP Code:
      $phoneNumberGroup $myEntity->getValueObject('phoneNumber'); 
      As a follow up question, when I am creating a new record, do I need to create the record BEFORE I add the value object?

      For example, can I do this:

      PHP Code:
      $myEntity $entityManager->getNewEntity('MyEntity');
      or do I need to create/save the Entity first before I can add the value object to the Entity object?