Skip to content
  • eileen's avatar
    Prevent hard error when a string is too long for a field. · 809e1a83
    eileen authored
    Over time we have had various requests to extend the length of various
    fields (currently https://github.com/civicrm/civicrm-core/pull/12939 ).
    
    The main issue is not that it matters to capture every single character of
    a crazy long user entered field - but that a hard fail when the data is too long can lose payment or registration or other data & provide a bad
    experience.
    
    This PR makes it still save, with a logged message & the utf friendly
    function in play. As of writing the api validation is stilltight - see
    ```
      // Check our field length
        throw new API_Exception("Value for $fieldName is " . strlen(utf8_decode($value)) . " characters  - This field has a maxlength of {$fieldInfo['maxlength']} characters.",
          2100, array('field' => $fieldName)
        );
      }
    ```
    and changing this is up for discussion.
    
    Note that at the UI level max field lengths can be enforced by using
    addField which uses metadata to determine field length etc
    809e1a83