RealEstate - name field is street address
Collapse
X
-
i can edit /fix without break anything
first in terminal
nano /var/www/html/custom/Espo/Modules/RealEstate/Hooks/RealEstateProperty/SetValues.php
and replace
$name = '';
if ($entity->get('addressStreet') || $entity->get('addressCity')) {
if ($entity->get('addressStreet')) {
$name .= str_replace("\n", ', ', $entity->get('addressStreet'));
}
if ($entity->get('addressCity')) {
if ($name != '') {
$name .= ", ";
}
$name .= $entity->get('addressCity');
}
}
else {
$name = "unknown-address";
}
$entity->set('name', $name);
To --------------------------------------------------------------
if (empty($entity->get('name'))) {
$name = '';
if ($entity->get('addressStreet') || $entity->get('addressCity')) {
if ($entity->get('addressStreet')) {
$name .= str_replace("\n", ', ', $entity->get('addressStreet'));
}
if ($entity->get('addressCity')) {
if ($name != '') {
$name .= ", ";
}
$name .= $entity->get('addressCity');
}
}
else {
$name = "unknown-address";
}
$entity->set('name', $name);
}
Finally only need to restart cache
php /var/www/html/clear_cache.php
-
2 - How to give a custom name to the Properties?
I looked in /application/Espo/Modules/RealEstate/repositories/RealEstateProperty.php :
but i'm afraid to mess around in the whole entity :
{
$propertyType = $entity->get('type');
$fieldList = $this->getMetadata()->get(['entityDefs', 'RealEstateProperty', 'propertyTypes', $propertyType, 'fieldList'], []);
$fieldDefs = $this->getMetadata()->get(['entityDefs', 'RealEstateProperty', 'fields'], []);
foreach ($fieldDefs as $field => $defs) {
if (empty($defs['isMatching'])) continue;
if (!in_array($field, $fieldList)) {
$entity->set($field, null);
}
}
$name = '';
if ($entity->get('addressStreet') || $entity->get('addressCity')) {
if ($entity->get('addressStreet')) {
$name .= str_replace("\n", ', ', $entity->get('addressStreet'));
}
if ($entity->get('addressCity')) {
if ($name != '') {
$name .= ", ";
}
$name .= $entity->get('addressCity');
}
} else {
$name = "unknown-address";
}
$entity->set('name', $name);
return parent::beforeSave($entity, $options);
}
could I turn it into this: ? (without messing around with something else) :
$name = $entity->get('name');
$entity->set('name', $name);
+ I added the 'name' field into the layouts in order to give a data to that field ^^
Thanks a lotLast edited by punkyard; 04-26-2021, 08:51 PM.Leave a comment:
-
if anyone can help, my questions would be :
1 - could it be possible to display a custom format option panel for the automatic nomination format of the RealEstateRequest Name field (R 000001)?
this could be useful to companies with their own formatting
how to play with? : (adding the date for example?)
if ($entity->isNew() && !$entity->get('name')) {
$e = $this->get($entity->id);
$name = strval($e->get('number'));
$name = str_pad($name, 6, '0', STR_PAD_LEFT);
$name = 'R' . $name;
$e->set('name', $name);
$this->save($e);
$entity->set('name', $name);
$entity->set('number', $e->get('number'));
Though, It is possible to uncheck the "read only" option in the entity manager, and type your own.Leave a comment:
-
I don't think too many people use the Real Estate extensions so you might have to figure this one out on your own by looking into the code. It not possible to do this through the GUI/admin.
The "Name" field used the following field:
Street Address, City
I use this extensions too but never look into changing it with code, the only thing I added was "Duplicate check" so I don't create two same addressLeave a comment:
-
RealEstate - name field is street address
hi
in the real estate extension, the name of a Property is the first address line
where is this stated in the entity settings?
how to change the name of the Property (top of the page) for a new field (ex: buildingName)?
thanksLast edited by punkyard; 04-26-2021, 08:54 PM.
Leave a comment: