| 1 | <?php |
||
| 10 | class Text_Field extends Field { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Key-value array of attribtues and their values |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $attributes = array( |
||
| 18 | 'type' => 'text', |
||
| 19 | ); |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Array of attributes the user is allowed to change |
||
| 23 | * |
||
| 24 | * @var array<string> |
||
| 25 | */ |
||
| 26 | protected $allowed_attributes = array( 'max', 'maxlength', 'min', 'pattern', 'placeholder', 'readonly', 'step', 'type' ); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set attribute and it's value |
||
| 30 | * |
||
| 31 | * @param string $name |
||
| 32 | * @param string $value |
||
| 33 | * @return Field $this |
||
| 34 | */ |
||
| 35 | public function set_attribute( $name, $value = '' ) { |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Returns an array that holds the field data, suitable for JSON representation. |
||
| 46 | * |
||
| 47 | * @param bool $load Should the value be loaded from the database or use the value from the current instance. |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | public function to_json( $load ) { |
||
| 59 | } |
||
| 60 |