| 1 | <?php |
||
| 2 | |||
| 3 | namespace LeKoala\FormElements; |
||
| 4 | |||
| 5 | use SilverStripe\Forms\LiteralField; |
||
| 6 | use SilverStripe\View\Requirements; |
||
| 7 | |||
| 8 | /** |
||
| 9 | */ |
||
| 10 | class FormatNumberField extends LiteralField |
||
| 11 | { |
||
| 12 | use BaseElement; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * @config |
||
| 16 | * @var boolean |
||
| 17 | */ |
||
| 18 | private static $enable_requirements = true; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $name |
||
| 22 | * @param string|FormField $content |
||
|
0 ignored issues
–
show
The type
LeKoala\FormElements\FormField was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 23 | * @param string $label |
||
| 24 | */ |
||
| 25 | public function __construct($name, $content = "", $title = null) |
||
| 26 | { |
||
| 27 | if ($content) { |
||
| 28 | $this->setContent($content); |
||
| 29 | } |
||
| 30 | if ($title) { |
||
| 31 | $this->setTitle($title); |
||
| 32 | } |
||
| 33 | |||
| 34 | parent::__construct($name, $content); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param array $properties |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | public function FieldHolder($properties = array()) |
||
| 42 | { |
||
| 43 | if (self::config()->enable_requirements) { |
||
| 44 | self::requirements(); |
||
| 45 | } |
||
| 46 | |||
| 47 | $content = parent::FieldHolder($properties); |
||
| 48 | $attrsHTML = $this->getElementAttributesHTML(); |
||
| 49 | $content = "<format-number value=\"{$content}\" $attrsHTML></format-number>"; |
||
| 50 | |||
| 51 | if ($this->title) { |
||
| 52 | $content = "<span>{$this->title}</span> " . $content; |
||
| 53 | } |
||
| 54 | return $content; |
||
| 55 | } |
||
| 56 | |||
| 57 | public static function requirements() |
||
| 58 | { |
||
| 59 | Requirements::javascript("lekoala/silverstripe-form-elements: client/custom-elements/format-number.min.js"); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Get the value of lang |
||
| 64 | */ |
||
| 65 | public function getLang() |
||
| 66 | { |
||
| 67 | return $this->getElementAttribute('lang'); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Set the value of lang |
||
| 72 | * |
||
| 73 | * @param mixed $lang |
||
| 74 | */ |
||
| 75 | public function setLang($lang) |
||
| 76 | { |
||
| 77 | return $this->setElementAttribute('lang', $lang); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Get the value of currency |
||
| 82 | */ |
||
| 83 | public function getCurrency() |
||
| 84 | { |
||
| 85 | return $this->getElementAttribute('currency'); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Set the value of currency |
||
| 90 | * |
||
| 91 | * @param mixed $currency |
||
| 92 | */ |
||
| 93 | public function setCurrency($currency) |
||
| 94 | { |
||
| 95 | return $this->setElementAttribute('currency', $currency); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Get the value of percent |
||
| 100 | */ |
||
| 101 | public function getPercent() |
||
| 102 | { |
||
| 103 | return $this->getElementAttribute('percent'); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Set the value of percent |
||
| 108 | * |
||
| 109 | * @param mixed $percent |
||
| 110 | */ |
||
| 111 | public function setPercent($percent) |
||
| 112 | { |
||
| 113 | return $this->setElementAttribute('percent', $percent); |
||
| 114 | } |
||
| 115 | } |
||
| 116 |