alleyinteractive / alleyinteractive/wordpress-fieldmanager

Passing `attributes` array to fields wipes out unrelated default attributes

Ouverte
#675 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
scope:field
Langage dominant
PHP
Étoiles
563
Forks
99
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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()`.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.