diff --git a/Core/Lib/Widget/WidgetMoney.php b/Core/Lib/Widget/WidgetMoney.php index eba521ec4b..275b2763da 100644 --- a/Core/Lib/Widget/WidgetMoney.php +++ b/Core/Lib/Widget/WidgetMoney.php @@ -31,9 +31,13 @@ class WidgetMoney extends WidgetNumber { protected $coddivisa; - public function showTableTotals(): bool + /** @param array $data */ + public function __construct($data) { - return true; + parent::__construct($data); + if (false === isset($data['totals'])) { + $this->showTotals = true; + } } /** @param object $model */ diff --git a/Core/Lib/Widget/WidgetNumber.php b/Core/Lib/Widget/WidgetNumber.php index 8defcab381..ca798b76cc 100644 --- a/Core/Lib/Widget/WidgetNumber.php +++ b/Core/Lib/Widget/WidgetNumber.php @@ -50,6 +50,13 @@ class WidgetNumber extends BaseWidget */ public $min; + /** + * Indicates if the totals should be shown. + * + * @var bool + */ + public $showTotals; + /** * Indicates the step value * @@ -66,6 +73,7 @@ public function __construct($data) $this->decimal = (int)($data['decimal'] ?? FS_NF0); $this->max = $data['max'] ?? ''; $this->min = $data['min'] ?? ''; + $this->showTotals = isset($data['totals']) && strtolower($data['totals']) === 'true'; $this->step = $data['step'] ?? 'any'; } @@ -84,6 +92,14 @@ public function processFormData(&$model, $request) $model->{$this->fieldname} = (float)$request->request->get($this->fieldname); } + /** + * @return bool + */ + public function showTableTotals(): bool + { + return $this->showTotals; + } + /** * @param string $type * @param string $extraClass