Source of file PercentageField.php

Size: 0,664 Bytes - Last Modified: 2021-12-23T10:00:38+00:00

/var/www/docs.ssmods.com/process/src/code/fields/PercentageField.php

12345678910111213141516171819202122232425262728
<?php

/**
 * PercentageField
 *
 * @author Kalyptus SPRL <thomas@kalyptus.be>
 */
class PercentageField extends DropdownField
{

    public function extraClass()
    {
        return 'dropdown ' . parent::extraClass();
    }

    public function __construct($name, $title = null, $source = array(), $value = '', $form = null, $emptyString = null)
    {
        if (empty($source)) {
            $source = [];
            foreach (range(0, 100) as $i) {
                $v = number_format($i / 100, 2);
                $source[(string) $v] = "$i %";
            }
        }
        parent::__construct($name, $title, $source, $value, $form, $emptyString);
    }
}