Concerns
3 years ago
Conditions
4 years ago
Contracts
3 years ago
Exceptions
3 years ago
Facades
4 years ago
FormFieldMediator
4 years ago
Checkbox.php
4 years ago
Date.php
4 years ago
Element.php
3 years ago
Email.php
4 years ago
Factory.php
4 years ago
Field.php
3 years ago
File.php
4 years ago
Form.php
3 years ago
Group.php
3 years ago
Hidden.php
4 years ago
Html.php
4 years ago
Option.php
4 years ago
Phone.php
4 years ago
Radio.php
4 years ago
Section.php
3 years ago
Select.php
4 years ago
Text.php
4 years ago
Textarea.php
4 years ago
Types.php
4 years ago
Url.php
4 years ago
Form.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\FieldsAPI; |
| 4 | |
| 5 | use Give\Framework\FieldsAPI\Contracts\Collection; |
| 6 | use Give\Framework\FieldsAPI\Contracts\Node; |
| 7 | use Give\Framework\FieldsAPI\Exceptions\TypeNotSupported; |
| 8 | |
| 9 | /** |
| 10 | * @since 2.12.0 |
| 11 | */ |
| 12 | class Form implements Node, Collection |
| 13 | { |
| 14 | use Concerns\HasLabel; |
| 15 | use Concerns\HasName; |
| 16 | use Concerns\HasNodes; |
| 17 | use Concerns\HasType; |
| 18 | use Concerns\InsertNode; |
| 19 | use Concerns\MoveNode; |
| 20 | use Concerns\NameCollision; |
| 21 | use Concerns\RemoveNode; |
| 22 | use Concerns\SerializeAsJson; |
| 23 | use Concerns\WalkNodes; |
| 24 | |
| 25 | const TYPE = 'form'; |
| 26 | |
| 27 | public function __construct($name) |
| 28 | { |
| 29 | $this->name = $name; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @since 2.14.0 |
| 34 | */ |
| 35 | public static function make($name) |
| 36 | { |
| 37 | return new static($name); |
| 38 | } |
| 39 | |
| 40 | public function getNodeType(): string |
| 41 | { |
| 42 | return 'group'; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @inheritDoc |
| 47 | * |
| 48 | * @param Section[] $nodes |
| 49 | * |
| 50 | * @throws TypeNotSupported |
| 51 | */ |
| 52 | public function append(Node ...$nodes) |
| 53 | { |
| 54 | foreach ($nodes as $node) { |
| 55 | if ( !$node instanceof Section ) { |
| 56 | throw new TypeNotSupported($node->getType()); |
| 57 | } |
| 58 | |
| 59 | $this->insertAtIndex($this->count(), $node); |
| 60 | } |
| 61 | |
| 62 | return $this; |
| 63 | } |
| 64 | } |
| 65 |