Announcement

Collapse
No announcement yet.

entityManager -> account -> edit: search fields

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

  • entityManager -> account -> edit: search fields

    Hi there

    Currently, in Accounts entity, my search fields are "name and email".

    But when i try to search with the default search input, and write "Paris" (for example), it does'nt find my account called "Villed de PAris".

    I think by default, it searchs with a filter "starts with" ?

    Currently, i have to use the filter feature to add "name" -> "contains" : "Paris" to find that account.

    Is it possible to change easily the default behaviour to find like "%$mysearch%" ?

    Thanks
    Click image for larger version

Name:	Capture d’écran 2017-09-25 à 12.44.54.png
Views:	457
Size:	45.2 KB
ID:	31303

  • #2
    Hmm, after digging into the code, i saw in SelectManagers/Base.php that :

    PHP Code:
    protected function textFilter($textFilter, &$result)
        {
            
    $fieldDefs $this->getSeed()->getAttributes();
            
    $fieldList $this->getTextFilterFieldList();
            
    $d = array();

            foreach (
    $fieldList as $field) {
                
    $expression $textFilter '%';
                if (
                    
    strlen($textFilter) >= self::MIN_LENGTH_FOR_CONTENT_SEARCH
                    
    &&
                    (
                        !empty(
    $fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'text'
                        
    ||
                        !empty(
    $this->textFilterUseContainsAttributeList[$field])
                        ||
                        !empty(
    $fieldDefs[$field]['type']) && $fieldDefs[$field]['type'] == 'varchar' &&
                        
    $this->getConfig()->get('textFilterUseContainsForVarchar')
                    )
                ) {
                    
    $expression '%' $textFilter '%';
                } else {
                    
    $expression $textFilter '%';
                }
                
    $d[$field '*'] = $expression;
            }
            
    $result['whereClause'][] = array(
                
    'OR' => $d
            
    );
        } 
    So, i just added in my config.php file :
    PHP Code:
    +    'textFilterUseContainsForVarchar' => true
    > rebuild

    and it seems to work :-)))

    Once again, so happy to have chosen this open source projet :-))

    One suggestion: it could be great to be able to configure that behaviour entity per entity

    For example, in Espo/Custom/Resources/metadata/entityDefs/Account.json
    it could be great to be able to override this behaviour

    PHP Code:
    "collection": {
    "sortBy""name",
    "asc"true,
    "textFilterFields": [
    "name",
    "emailAddress",
    "phoneNumber"
    + ],
    'textFilterUseContainsForVarchar' => true,

    Comment


    • #3
      This setting option cannot be configured through the UI. Any reason ?

      Do you think we should update
      application/Espo/Resources/layouts/Settings/settings.json
      application/Espo/Resources/metadata/entityDefs/Settings.json

      to properly set *textFilterUseContainsForVarchar* there ?

      Let me know if you want that i open a PR for that ?
      (cc tanya )

      Comment


      • #4
        Hello

        It's great that you found a solution in a short time
        Sorry, don't need this.

        Thanks

        Comment


        • #5
          Ok thanks for you feedback, so i don't implement and don't open a PR for that

          Comment

          Working...
          X