# danog\MadelineProto\WebUI\Field: A form field.

[Back to index](../../../index.html)

> Author: Daniil Gentili <daniil@daniil.it>  
  

A form field.  



## Properties
* `$name`: `string` 
* `$label`: `string` 
* `$type`: `danog\MadelineProto\WebUI\FieldType` 
* `$value`: `string` 
* `$placeholder`: `string` 
* `$hint`: `(danog\MadelineProto\WebUI\SafeHtml | string)` 
* `$required`: `bool` 
* `$autocomplete`: `?string` 
* `$options`: `array` 
* `$showWhen`: `?array` 
* `$autofocus`: `bool` 
* `$maxLength`: `?int` 

## Method list:
* [`__construct(string $name, string $label, \danog\MadelineProto\WebUI\FieldType $type = \danog\MadelineProto\WebUI\FieldType::TEXT, string $value = '', string $placeholder = '', \danog\MadelineProto\WebUI\SafeHtml|string $hint = '', bool $required = true, ?string $autocomplete = NULL, array<string, string> $options = [], ?array{0: string, 1: string} $showWhen = NULL, bool $autofocus = false, ?int $maxLength = NULL)`](#__construct)
* [`jsonSerialize(): array`](#jsonSerialize)
* [`getInputAttributes(string $id): array<string, (scalar|null)>`](#getInputAttributes)

## Methods:
### <a name="__construct"></a> `__construct(string $name, string $label, \danog\MadelineProto\WebUI\FieldType $type = \danog\MadelineProto\WebUI\FieldType::TEXT, string $value = '', string $placeholder = '', \danog\MadelineProto\WebUI\SafeHtml|string $hint = '', bool $required = true, ?string $autocomplete = NULL, array<string, string> $options = [], ?array{0: string, 1: string} $showWhen = NULL, bool $autofocus = false, ?int $maxLength = NULL)`




Parameters:

* `$name`: `string` Name of the POST parameter  
* `$label`: `string` Label  
* `$type`: `\danog\MadelineProto\WebUI\FieldType`   
* `$value`: `string`   
* `$placeholder`: `string`   
* `$hint`: `\danog\MadelineProto\WebUI\SafeHtml|string`   
* `$required`: `bool`   
* `$autocomplete`: `?string` Value of the autocomplete attribute  
* `$options`: `array<string, string>` Value => label, for {@see FieldType::CHOICE}  
* `$showWhen`: `?array{0: string, 1: string}` Only show (and submit) the field when the CHOICE field with the given name has the given value  
* `$autofocus`: `bool`   
* `$maxLength`: `?int`   


#### See also: 
* [`\danog\MadelineProto\WebUI\FieldType`: Type of a form field.](../../../danog/MadelineProto/WebUI/FieldType.html)
* [`\danog\MadelineProto\WebUI\SafeHtml`: A trusted HTML fragment, output as-is by templates instead of being escaped.](../../../danog/MadelineProto/WebUI/SafeHtml.html)




### <a name="jsonSerialize"></a> `jsonSerialize(): array`





### <a name="getInputAttributes"></a> `getInputAttributes(string $id): array<string, (scalar|null)>`

Get the attributes of the input element.


Parameters:

* `$id`: `string`   


#### See also: 
* `scalar`




---
Generated by [danog/phpdoc](https://phpdoc.daniil.it)
