1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Chromabits\Nucleus\View\Common;
13:
14: use Chromabits\Nucleus\Meditation\Constraints\InArrayConstraint;
15: use Chromabits\Nucleus\Meditation\Constraints\PrimitiveTypeConstraint;
16: use Chromabits\Nucleus\Meditation\Primitives\CompoundTypes;
17: use Chromabits\Nucleus\Meditation\Primitives\ScalarTypes;
18: use Chromabits\Nucleus\Meditation\Spec;
19: use Chromabits\Nucleus\View\Interfaces\RenderableInterface;
20: use Chromabits\Nucleus\View\Node;
21:
22: 23: 24: 25: 26: 27:
28: class Button extends Node
29: {
30: const TYPE_SUBMIT = 'submit';
31: const TYPE_RESET = 'reset';
32: const TYPE_BUTTON = 'button';
33:
34: 35: 36: 37: 38: 39:
40: public function __construct($attributes, $content = '')
41: {
42: parent::__construct('button', $attributes, $content);
43:
44: $this->spec = new Spec([
45: 'autofocus'
46: => new PrimitiveTypeConstraint(CompoundTypes::COMPOUND_ARRAY),
47: 'autocomplete'
48: => new PrimitiveTypeConstraint(CompoundTypes::COMPOUND_ARRAY),
49: 'disabled'
50: => new PrimitiveTypeConstraint(ScalarTypes::SCALAR_BOOLEAN),
51: 'form' => new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING),
52: 'name' => new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING),
53: 'type' => new InArrayConstraint([
54: static::TYPE_SUBMIT,
55: static::TYPE_BUTTON,
56: static::TYPE_RESET,
57: ]),
58: 'value' => new PrimitiveTypeConstraint(ScalarTypes::SCALAR_STRING),
59: ]);
60: }
61: }
62: