| Total Complexity | 7 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class SelectedColourPickerFormFieldDropdown extends DropdownField |
||
| 11 | { |
||
| 12 | |||
| 13 | protected $limitedToOptions = true; |
||
| 14 | |||
| 15 | protected $isBgColour = true; |
||
| 16 | |||
| 17 | public function setLimitedToOptions(bool $bool) |
||
| 18 | { |
||
| 19 | $this->limitedToOptions = $bool; |
||
| 20 | |||
| 21 | return $this; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function setIsBgColour(bool $bool) |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Validate this field. |
||
| 33 | * |
||
| 34 | * @param Validator $validator |
||
| 35 | * |
||
| 36 | * @return bool |
||
| 37 | */ |
||
| 38 | public function validate($validator) |
||
| 39 | { |
||
| 40 | if ($this->limitedToOptions && $this->value && ! isset($this->source[$this->value])) { |
||
| 41 | $validator->validationError( |
||
| 42 | $this->name, |
||
| 43 | 'Please selected from suggested options only', |
||
| 44 | 'validation' |
||
| 45 | ); |
||
| 46 | |||
| 47 | return false; |
||
| 48 | } |
||
| 49 | |||
| 50 | return true; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function Field($properties = []) |
||
| 68 | } |
||
| 69 | } |
||
| 70 |