-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field Types: Make object oriented, support custom field types. #45
Comments
Possible implementation of interface interface FieldTypeInterface
{
public function __construct(array $params);
/**
* @brief render functions take the object and the key and return something Renderable.
*/
public function renderEdit($object,$key,$value);
public function renderList($object,$key,$value);
public function renderView($object,$key,$value);
public function validations() : array;
} Questions to answer
|
This seems like a breaking change, since Changelog for users
Do you think it would be worth it to provide some kind of support for |
I think we can work with this and target v1.0.0 since I have not actually versioned it to anything at the moment. This package is still in it's infancy so I think breaking changes.. would be a given. I'm not too sure about the usage of Otter in production as I don't have any tracking of sorts but if we base the amount of users off the statistics from packagist, I think we're good to make the breaking change for a better modular package. |
Thinking more about this: passing them as objects shouldn't hurt anything, performance-wise, we're only ELV-ing one thing at a time anyway. Also, then we can just allow each one to define its own constructor! Hooray! return [
'name' => new BasicField('text'),
'password' => new PasswordField(),
'email' => BasicField('email'),
'purpose_statement' => TextAreaField(),
'biography' => TextAreaField(['rows' => 20]),
'favorite_color' => ColorField(), And looking at my This leaves us still without a way of getting two keys. I think the Personally, I'm not too concerned with validations (I just don't know that I'd use it), so I won't make major suggestions for change here (so, maybe I'll accidentally break it on implementation). Architecturally, it seems like something that should be moved inside |
A few concerns with allowing or recommending the use of non-fields as keys: They can't be used in * Facet, Edit, List, View For faceting, I think we would want to allow the search box to modify the model query that is happening with 1 or more e.g. Different fields might want to define their own verbs: Maybe that's pushing it too far (we could use leverage eloquent query scopes for some of this). That being said, I think enough of the thinking about this is done for it to start. |
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-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
The text was updated successfully, but these errors were encountered: