yiisoft /
form
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | declare(strict_types=1); |
||||||
| 4 | |||||||
| 5 | namespace Yiisoft\Form; |
||||||
| 6 | |||||||
| 7 | use Yiisoft\Form\Field\Base\InputData\PureInputData; |
||||||
| 8 | use Yiisoft\Form\Field\Button; |
||||||
| 9 | use Yiisoft\Form\Field\ButtonGroup; |
||||||
| 10 | use Yiisoft\Form\Field\Checkbox; |
||||||
| 11 | use Yiisoft\Form\Field\CheckboxList; |
||||||
| 12 | use Yiisoft\Form\Field\Date; |
||||||
| 13 | use Yiisoft\Form\Field\DateTime; |
||||||
| 14 | use Yiisoft\Form\Field\DateTimeLocal; |
||||||
| 15 | use Yiisoft\Form\Field\Email; |
||||||
| 16 | use Yiisoft\Form\Field\ErrorSummary; |
||||||
| 17 | use Yiisoft\Form\Field\Fieldset; |
||||||
| 18 | use Yiisoft\Form\Field\File; |
||||||
| 19 | use Yiisoft\Form\Field\Hidden; |
||||||
| 20 | use Yiisoft\Form\Field\Image; |
||||||
| 21 | use Yiisoft\Form\Field\Number; |
||||||
| 22 | use Yiisoft\Form\Field\Part\Error; |
||||||
| 23 | use Yiisoft\Form\Field\Part\Hint; |
||||||
| 24 | use Yiisoft\Form\Field\Part\Label; |
||||||
| 25 | use Yiisoft\Form\Field\Password; |
||||||
| 26 | use Yiisoft\Form\Field\RadioList; |
||||||
| 27 | use Yiisoft\Form\Field\Range; |
||||||
| 28 | use Yiisoft\Form\Field\ResetButton; |
||||||
| 29 | use Yiisoft\Form\Field\Select; |
||||||
| 30 | use Yiisoft\Form\Field\SubmitButton; |
||||||
| 31 | use Yiisoft\Form\Field\Telephone; |
||||||
| 32 | use Yiisoft\Form\Field\Text; |
||||||
| 33 | use Yiisoft\Form\Field\Textarea; |
||||||
| 34 | use Yiisoft\Form\Field\Time; |
||||||
| 35 | use Yiisoft\Form\Field\Url; |
||||||
| 36 | |||||||
| 37 | /** |
||||||
| 38 | * @psalm-import-type Errors from ErrorSummary |
||||||
| 39 | */ |
||||||
| 40 | class PureField |
||||||
| 41 | { |
||||||
| 42 | /** |
||||||
| 43 | * @var string|null |
||||||
| 44 | */ |
||||||
| 45 | protected const DEFAULT_THEME = null; |
||||||
| 46 | |||||||
| 47 | 3 | final public static function button(?string $content = null, array $config = [], ?string $theme = null): Button |
|||||
| 48 | { |
||||||
| 49 | 3 | $field = Button::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
| 50 | |||||||
| 51 | 3 | if ($content !== null) { |
|||||
| 52 | 1 | $field = $field->content($content); |
|||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 53 | } |
||||||
| 54 | |||||||
| 55 | 3 | return $field; |
|||||
| 56 | } |
||||||
| 57 | |||||||
| 58 | 2 | final public static function buttonGroup(array $config = [], ?string $theme = null): ButtonGroup |
|||||
| 59 | { |
||||||
| 60 | 2 | return ButtonGroup::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
|
0 ignored issues
–
show
|
|||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | 2 | final public static function checkbox( |
|||||
| 64 | ?string $name = null, |
||||||
| 65 | mixed $value = null, |
||||||
| 66 | array $config = [], |
||||||
| 67 | ?string $theme = null, |
||||||
| 68 | ): Checkbox { |
||||||
| 69 | 2 | return Checkbox::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 70 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
|
0 ignored issues
–
show
The method
inputData() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Field\Part\Label or Yiisoft\Form\Field\Part\Error or Yiisoft\Form\Field\Part\Hint or Yiisoft\Form\Field\RadioList or Yiisoft\Form\Field\Base\InputField or Yiisoft\Form\Field\CheckboxList.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 71 | } |
||||||
| 72 | |||||||
| 73 | 2 | final public static function checkboxList( |
|||||
| 74 | ?string $name = null, |
||||||
| 75 | mixed $value = null, |
||||||
| 76 | array $config = [], |
||||||
| 77 | ?string $theme = null, |
||||||
| 78 | ): CheckboxList { |
||||||
| 79 | 2 | return CheckboxList::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 80 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | 2 | final public static function date( |
|||||
| 84 | ?string $name = null, |
||||||
| 85 | mixed $value = null, |
||||||
| 86 | array $config = [], |
||||||
| 87 | ?string $theme = null, |
||||||
| 88 | ): Date { |
||||||
| 89 | 2 | return Date::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 90 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 91 | } |
||||||
| 92 | |||||||
| 93 | 2 | final public static function dateTime( |
|||||
| 94 | ?string $name = null, |
||||||
| 95 | mixed $value = null, |
||||||
| 96 | array $config = [], |
||||||
| 97 | ?string $theme = null, |
||||||
| 98 | ): DateTime { |
||||||
| 99 | 2 | return DateTime::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 100 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 101 | } |
||||||
| 102 | |||||||
| 103 | 2 | final public static function dateTimeLocal( |
|||||
| 104 | ?string $name = null, |
||||||
| 105 | mixed $value = null, |
||||||
| 106 | array $config = [], |
||||||
| 107 | ?string $theme = null, |
||||||
| 108 | ): DateTimeLocal { |
||||||
| 109 | 2 | return DateTimeLocal::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 110 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 111 | } |
||||||
| 112 | |||||||
| 113 | 2 | final public static function email( |
|||||
| 114 | ?string $name = null, |
||||||
| 115 | mixed $value = null, |
||||||
| 116 | array $config = [], |
||||||
| 117 | ?string $theme = null, |
||||||
| 118 | ): Email { |
||||||
| 119 | 2 | return Email::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 120 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 121 | } |
||||||
| 122 | |||||||
| 123 | /** |
||||||
| 124 | * @psalm-param Errors $errors |
||||||
| 125 | */ |
||||||
| 126 | 2 | final public static function errorSummary( |
|||||
| 127 | array $errors = [], |
||||||
| 128 | array $config = [], |
||||||
| 129 | ?string $theme = null, |
||||||
| 130 | ): ErrorSummary { |
||||||
| 131 | 2 | return ErrorSummary::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME)->errors($errors); |
|||||
|
0 ignored issues
–
show
The method
errors() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Field\ErrorSummary.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 132 | } |
||||||
| 133 | |||||||
| 134 | 2 | final public static function fieldset(array $config = [], ?string $theme = null): Fieldset |
|||||
| 135 | { |
||||||
| 136 | 2 | return Fieldset::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
|
0 ignored issues
–
show
|
|||||||
| 137 | } |
||||||
| 138 | |||||||
| 139 | 2 | final public static function file( |
|||||
| 140 | ?string $name = null, |
||||||
| 141 | mixed $value = null, |
||||||
| 142 | array $config = [], |
||||||
| 143 | ?string $theme = null, |
||||||
| 144 | ): File { |
||||||
| 145 | 2 | return File::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 146 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 147 | } |
||||||
| 148 | |||||||
| 149 | 3 | final public static function hidden( |
|||||
| 150 | ?string $name = null, |
||||||
| 151 | mixed $value = null, |
||||||
| 152 | array $config = [], |
||||||
| 153 | ?string $theme = null, |
||||||
| 154 | ): Hidden { |
||||||
| 155 | 3 | return Hidden::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 156 | 3 | ->inputData(new PureInputData($name, $value)); |
|||||
| 157 | } |
||||||
| 158 | |||||||
| 159 | 3 | final public static function image(?string $url = null, array $config = [], ?string $theme = null): Image |
|||||
| 160 | { |
||||||
| 161 | 3 | $field = Image::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
| 162 | |||||||
| 163 | 3 | if ($url !== null) { |
|||||
| 164 | 1 | $field = $field->src($url); |
|||||
|
0 ignored issues
–
show
The method
src() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Field\Image.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 165 | } |
||||||
| 166 | |||||||
| 167 | 3 | return $field; |
|||||
| 168 | } |
||||||
| 169 | |||||||
| 170 | 2 | final public static function number( |
|||||
| 171 | ?string $name = null, |
||||||
| 172 | mixed $value = null, |
||||||
| 173 | array $config = [], |
||||||
| 174 | ?string $theme = null, |
||||||
| 175 | ): Number { |
||||||
| 176 | 2 | return Number::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 177 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 178 | } |
||||||
| 179 | |||||||
| 180 | 2 | final public static function password( |
|||||
| 181 | ?string $name = null, |
||||||
| 182 | mixed $value = null, |
||||||
| 183 | array $config = [], |
||||||
| 184 | ?string $theme = null, |
||||||
| 185 | ): Password { |
||||||
| 186 | 2 | return Password::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 187 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 188 | } |
||||||
| 189 | |||||||
| 190 | 2 | final public static function radioList( |
|||||
| 191 | ?string $name = null, |
||||||
| 192 | mixed $value = null, |
||||||
| 193 | array $config = [], |
||||||
| 194 | ?string $theme = null, |
||||||
| 195 | ): RadioList { |
||||||
| 196 | 2 | return RadioList::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 197 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 198 | } |
||||||
| 199 | |||||||
| 200 | 2 | final public static function range( |
|||||
| 201 | ?string $name = null, |
||||||
| 202 | mixed $value = null, |
||||||
| 203 | array $config = [], |
||||||
| 204 | ?string $theme = null, |
||||||
| 205 | ): Range { |
||||||
| 206 | 2 | return Range::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 207 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 208 | } |
||||||
| 209 | |||||||
| 210 | 3 | final public static function resetButton( |
|||||
| 211 | ?string $content = null, |
||||||
| 212 | array $config = [], |
||||||
| 213 | ?string $theme = null, |
||||||
| 214 | ): ResetButton { |
||||||
| 215 | 3 | $field = ResetButton::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
| 216 | |||||||
| 217 | 3 | if ($content !== null) { |
|||||
| 218 | 1 | $field = $field->content($content); |
|||||
| 219 | } |
||||||
| 220 | |||||||
| 221 | 3 | return $field; |
|||||
| 222 | } |
||||||
| 223 | |||||||
| 224 | 2 | final public static function select( |
|||||
| 225 | ?string $name = null, |
||||||
| 226 | mixed $value = null, |
||||||
| 227 | array $config = [], |
||||||
| 228 | ?string $theme = null, |
||||||
| 229 | ): Select { |
||||||
| 230 | 2 | return Select::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 231 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 232 | } |
||||||
| 233 | |||||||
| 234 | 3 | final public static function submitButton( |
|||||
| 235 | ?string $content = null, |
||||||
| 236 | array $config = [], |
||||||
| 237 | ?string $theme = null, |
||||||
| 238 | ): SubmitButton { |
||||||
| 239 | 3 | $field = SubmitButton::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME); |
|||||
| 240 | |||||||
| 241 | 3 | if ($content !== null) { |
|||||
| 242 | 1 | $field = $field->content($content); |
|||||
| 243 | } |
||||||
| 244 | |||||||
| 245 | 3 | return $field; |
|||||
| 246 | } |
||||||
| 247 | |||||||
| 248 | 2 | final public static function telephone( |
|||||
| 249 | ?string $name = null, |
||||||
| 250 | mixed $value = null, |
||||||
| 251 | array $config = [], |
||||||
| 252 | ?string $theme = null, |
||||||
| 253 | ): Telephone { |
||||||
| 254 | 2 | return Telephone::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 255 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 256 | } |
||||||
| 257 | |||||||
| 258 | 4 | final public static function text( |
|||||
| 259 | ?string $name = null, |
||||||
| 260 | mixed $value = null, |
||||||
| 261 | array $config = [], |
||||||
| 262 | ?string $theme = null, |
||||||
| 263 | ): Text { |
||||||
| 264 | 4 | return Text::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 265 | 4 | ->inputData(new PureInputData($name, $value)); |
|||||
| 266 | } |
||||||
| 267 | |||||||
| 268 | 2 | final public static function textarea( |
|||||
| 269 | ?string $name = null, |
||||||
| 270 | mixed $value = null, |
||||||
| 271 | array $config = [], |
||||||
| 272 | ?string $theme = null, |
||||||
| 273 | ): Textarea { |
||||||
| 274 | 2 | return Textarea::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 275 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 276 | } |
||||||
| 277 | |||||||
| 278 | 2 | final public static function time( |
|||||
| 279 | ?string $name = null, |
||||||
| 280 | mixed $value = null, |
||||||
| 281 | array $config = [], |
||||||
| 282 | ?string $theme = null, |
||||||
| 283 | ): Time { |
||||||
| 284 | 2 | return Time::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 285 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 286 | } |
||||||
| 287 | |||||||
| 288 | 2 | final public static function url( |
|||||
| 289 | ?string $name = null, |
||||||
| 290 | mixed $value = null, |
||||||
| 291 | array $config = [], |
||||||
| 292 | ?string $theme = null, |
||||||
| 293 | ): Url { |
||||||
| 294 | 2 | return Url::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME) |
|||||
| 295 | 2 | ->inputData(new PureInputData($name, $value)); |
|||||
| 296 | } |
||||||
| 297 | |||||||
| 298 | 3 | final public static function label(?string $content = null, array $config = [], ?string $theme = null): Label |
|||||
| 299 | { |
||||||
| 300 | 3 | return Label::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME)->content($content); |
|||||
| 301 | } |
||||||
| 302 | |||||||
| 303 | 3 | final public static function hint(?string $content = null, array $config = [], ?string $theme = null): Hint |
|||||
| 304 | { |
||||||
| 305 | 3 | return Hint::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME)->content($content); |
|||||
| 306 | } |
||||||
| 307 | |||||||
| 308 | 3 | final public static function error(?string $message = null, array $config = [], ?string $theme = null): Error |
|||||
| 309 | { |
||||||
| 310 | 3 | return Error::widget(config: $config, theme: $theme ?? static::DEFAULT_THEME)->message($message); |
|||||
|
0 ignored issues
–
show
The method
message() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Form\Field\Part\Error.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 311 | } |
||||||
| 312 | } |
||||||
| 313 |