Merge pull request #22438 from eileenmcnaughton/format
[civicrm-core.git] / Civi / Schema / Traits / GuiSpecTrait.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 namespace Civi\Schema\Traits;
13
14 /**
15 * If a field will be presented in GUIs (e.g. data-entry fields or
16 * data-columns), then use GuiSpecTrait to describe its typical/default appearance..
17 *
18 * @package Civi\Schema\Traits
19 */
20 trait GuiSpecTrait {
21
22 /**
23 * User-facing label, shown on most forms and displays
24 *
25 * Default label to use when presenting this field to an end-user (e.g.
26 * on a data-entry form or a data-column view).
27 *
28 * @var string
29 */
30 public $label;
31
32 /**
33 * Default widget to use when presenting this field.
34 *
35 * @var string
36 * Ex: 'RichTextEditor'
37 */
38 public $inputType;
39
40 /**
41 * @var array
42 */
43 public $inputAttrs = [];
44
45 /**
46 * @var string
47 */
48 public $helpPre;
49
50 /**
51 * @var string
52 */
53 public $helpPost;
54
55 /**
56 * @return string
57 */
58 public function getLabel() {
59 return $this->label;
60 }
61
62 /**
63 * @return string
64 */
65 public function getInputType() {
66 return $this->inputType;
67 }
68
69 /**
70 * @param string $inputType
71 *
72 * @return $this
73 */
74 public function setInputType($inputType) {
75 $this->inputType = $inputType;
76 return $this;
77 }
78
79 /**
80 * @return array
81 */
82 public function getInputAttrs() {
83 return $this->inputAttrs;
84 }
85
86 /**
87 * @param array $inputAttrs
88 *
89 * @return $this
90 */
91 public function setInputAttrs($inputAttrs) {
92 $this->inputAttrs = $inputAttrs;
93 return $this;
94 }
95
96 /**
97 * @param string $label
98 *
99 * @return $this
100 */
101 public function setLabel($label) {
102 $this->label = $label;
103 return $this;
104 }
105
106 /**
107 * @param string|null $helpPre
108 */
109 public function setHelpPre($helpPre) {
110 $this->helpPre = is_string($helpPre) && strlen($helpPre) ? $helpPre : NULL;
111 }
112
113 /**
114 * @param string|null $helpPost
115 */
116 public function setHelpPost($helpPost) {
117 $this->helpPost = is_string($helpPost) && strlen($helpPost) ? $helpPost : NULL;
118 }
119
120 }