Currently, field types are defined by simple strings. This makes it easy to define a list of attributes, but lets say I wanted some more custom field types
class User extends OtterResource
{
public function fields() {
return [
'name' => 'text',
'password' => 'password',
'email' => 'email',
'purpose_statement' => 'textarea',
'biography' => 'textarea',
'favorite_color' => 'color',
];
}
...
Currently, #43 implements the textarea by changing FormComponent.vue, SingleResourceComponent.vue, and TableComponent.vue. While this works for the previous example, it's hard to customize.
For example, if I wanted the table view of 'favorite_color' to just show the favorite color (instead of the string #000000, I would need to customize FormComponent.vue to have another if statement in it. If I wanted to increase the number of rows in the textarea element for biography, I would need to define a textarea-longer type, and write if statements to make sure those got carried over.
Proposal: Create an Object Interface defining rendering for the listing, viewing, and editing interfaces. Allow parameters to be set for each one. (Also allow these to define defaults for 'hidden' and 'validations')
Possible usage
public function fieldTypes() {
return [
'name' => [BasicField::class, ['type' => 'text'],],
'password' => PasswordField::class,
'email' => [BasicField::class, ['type' => 'email'],],
'purpose_statement' => TextAreaField::class,
'biography' => [TextAreaField::class, ['rows' => 20],],
'favorite_color' => ColorField::class,
];
Currently, field types are defined by simple strings. This makes it easy to define a list of attributes, but lets say I wanted some more custom field types
Currently, #43 implements the textarea by changing FormComponent.vue, SingleResourceComponent.vue, and TableComponent.vue. While this works for the previous example, it's hard to customize.
For example, if I wanted the table view of 'favorite_color' to just show the favorite color (instead of the string
#000000, I would need to customize FormComponent.vue to have another if statement in it. If I wanted to increase the number of rows in the textarea element forbiography, I would need to define atextarea-longertype, and write if statements to make sure those got carried over.Proposal: Create an Object Interface defining rendering for the listing, viewing, and editing interfaces. Allow parameters to be set for each one. (Also allow these to define defaults for 'hidden' and 'validations')
Possible usage