diff --git a/app/src/Model/Table/ProvisioningHistoryRecordsTable.php b/app/src/Model/Table/ProvisioningHistoryRecordsTable.php index e9e0cdc81..321e7e984 100644 --- a/app/src/Model/Table/ProvisioningHistoryRecordsTable.php +++ b/app/src/Model/Table/ProvisioningHistoryRecordsTable.php @@ -100,6 +100,25 @@ public function initialize(array $config): void { ]); } + /** + * Perform actions while marshaling data, before validation. + * + * @since COmanage Registry v5.0.0 + * @param EventInterface $event Event + * @param ArrayObject $data Object data, in array format + * @param ArrayObject $options Entity save options + */ + + public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayObject $options) + { + if(!empty($data['comment'])) { + // Truncate the comment to fit the column width + $column = $this->getSchema()->getColumn('comment'); + + $data['comment'] = substr($data['comment'], 0, $column['length']); + } + } + /** * Table specific logic to generate a display field. *