| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Framework\FieldsAPI; |
| 4 |
|
| 5 |
use InvalidArgumentException; |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 3.0.0 |
| 9 |
*/ |
| 10 |
class MultiSelect extends Field |
| 11 |
{ |
| 12 |
use Concerns\AllowMultiple; |
| 13 |
use Concerns\HasEmailTag; |
| 14 |
use Concerns\HasHelpText; |
| 15 |
use Concerns\HasLabel; |
| 16 |
use Concerns\HasOptions; |
| 17 |
use Concerns\HasPlaceholder; |
| 18 |
use Concerns\HasDescription; |
| 19 |
|
| 20 |
protected $fieldType; |
| 21 |
|
| 22 |
const TYPE = 'multiSelect'; |
| 23 |
|
| 24 |
/** |
| 25 |
* @since 3.0.0 |
| 26 |
*/ |
| 27 |
public function getFieldType(): string |
| 28 |
{ |
| 29 |
return $this->fieldType; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* @since 3.0.0 |
| 34 |
*/ |
| 35 |
public function fieldType(string $fieldType): MultiSelect |
| 36 |
{ |
| 37 |
if (!in_array($fieldType, ['checkbox', 'dropdown'])) { |
| 38 |
throw new InvalidArgumentException(__('Field type must be either "checkbox" or "dropdown".', 'give')); |
| 39 |
} |
| 40 |
|
| 41 |
$this->fieldType = $fieldType; |
| 42 |
|
| 43 |
return $this; |
| 44 |
} |
| 45 |
} |
| 46 |
|