Is there a way to add a wrapper around a labelfield or any other kind of form field in silverstripe forms?
It would be easier to style forms this way.
FieldList::create( LabelField::create('label','Label'), EmailField::create('Email',''), TextareaField::create('Comment','') )
Yes, according to the docs you can set a template either per form or per field, see docs.
$field = TextField::create(..); $field->setTemplate('MyCustomTextField');
You need to set the whole path to your template if it’s located in a subfolder of your themes
If you need to change the templates globally you can overwrite them in your theme. LabelField’s template is located in
Put a file with the same path in your theme (e.g.
flush your Silverstripe cache (e.g. by running flush by adding
?flushto the URL) so Silverstripe can find the new
and start experimenting with your custom markup.
A flush is only needed when you add a new template file, updates of your existing files will be detected automatically.