Skip to content
Snippets Groups Projects
Unverified Commit 3997f290 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

feat: add possibility to manipulate field type

parent 2fb38d0f
No related branches found
No related tags found
2 merge requests!28release: 3.0.0,!19Add strong typing for 3.0 version
......@@ -29,6 +29,7 @@ abstract class BasicField implements Field {
'description' => '',
'description_tip' => '',
'data' => [],
'type' => 'text',
];
public function should_override_form_template(): bool {
......@@ -36,7 +37,13 @@ abstract class BasicField implements Field {
}
public function get_type(): string {
return 'text';
return $this->meta['type'];
}
public function set_type( string $type ): Field {
$this->meta['type'] = $type;
return $this;
}
public function get_validator(): Validator {
......
......@@ -6,6 +6,10 @@ use WPDesk\Forms\Field;
class SelectField extends BasicField {
public function get_type(): string {
return 'select';
}
public function get_template_name(): string {
return 'select';
}
......
......@@ -4,6 +4,10 @@ namespace WPDesk\Forms\Field;
class TextAreaField extends BasicField {
public function get_type(): string {
return 'textarea';
}
public function get_template_name(): string {
return 'textarea';
}
......
......@@ -7,6 +7,10 @@ use WPDesk\Forms\Serializer\JsonSerializer;
class TimepickerField extends BasicField {
public function get_type(): string {
return 'time';
}
public function has_serializer(): bool {
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment