alleyinteractive / alleyinteractive/wordpress-fieldmanager
Passing `attributes` array to fields wipes out unrelated default attributes
- Linguagem predominante
- PHP
- Estrelas
- 563
- Forks
- 99
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
As noted by @vancoder, instantiating a field with `[ 'attributes' => [ 'foo' => 'bar' ] ]` will remove all of the field's default `attributes`, instead of, as might be expected, overwriting any default for `foo` but preserving other defaults like `size`.
Assuming this behavior isn't intentional, some top-of-the-head ideas for addressing it:
- Add a `attributes_defaults` property to `Fieldmanager_Field` that's merged into the `attributes` property at the end of `Fieldmanager_Field::set_options()`.
- Add logic to the beginning of `Fieldmanager_Field::set_options()` that merges the `attributes` property at that moment with the incoming ones in `$options`, if any.
- Make it each field's responsibility to merge their defaults into `attributes` after calling `parent::__construct()`.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.