Open kinglozzer opened 5 years ago
Temporary workaround (eg for placeholder attribute):
$field->setSchemaData(['attributes' => ['placeholder' => 'My placeholder value']]);
I think the way forward for this is in a major release call getAttributes()
from getSchemaDataDefaults()
, and make sure to update any core and supported modules to not call getSchemaData()
in getAttributes()
(e.g. TreeDropdownField
- those data attributes should be added in the template directly instead, perhaps)
FormField::getSchemaDataDefaults()
by default returns an empty array for the field’s attributes (third-last item in the below array):https://github.com/silverstripe/silverstripe-framework/blob/29a663c65d1efa819ffbbb5f964c33bd2f10780d/src/Forms/FormField.php#L1538-L1560
I noticed this when adding a new field to
GridFieldFilterHeader
, any attributes I add to the field go missing as it’s built using the form schema. Workaround is to just use->setSchemaData()
to add the attributes manuallyChanging it toEdit: that won’t work because recursion https://github.com/silverstripe/silverstripe-framework/pull/9125#issuecomment-511347274'attributes' => $this->getAttributes(),
has the desired effect.