Through new methods on the FormField, CSS classes can be added to any Field Holder template. That is, to the opening div, Validation span, Middle Column/Description div, and Left/Right label.
Through new methods on the FormField, CSS classes can be added to any Field Holder template. That is, to the opening div, Validation span, Middle Column/Description div, and Left/Right label.
For styling of Form Fields
Extends the FormField
class
CheckboxField::create('Example', 'Checkbox Example')
->addHolderClass('form-check')
->addRightLabelClass('form-check-label')
->addExtraClass('form-check-input') // note: existing SilverStripe functionality
->addHolderValidationMessageClass('alert alert-danger')
->addHolderDescriptionClass('blueday');
Would create:
<div id="Form_Form_CheckboxFieldExample_Holder" class="field checkbox form-check">
<input type="checkbox" name="Example" value="1" class="checkbox form-check-input" id="Form_Form_Example">
<label class="right form-check-label" for="Form_Form_Example">Checkbox Example</label>
<span class="message alert alert-danger bad">Opps!</span>
<span class="description blueday">Helpful note to the user</span>
</div>
The classes in this module mostly apply to the Field Holder template. The central $Field
remains untouched (the existing SilverStripe function addExtraClass
can be used to add CSS classes to this). Note: the addExtraClass
has been removed from the holder templates now that there are new methods to use. In addition, default classes are in place that match the existing classes in the SilverStripe holder templates so there should not be too much carnage when installing this module into an existing project.
Feel free to send a pull request. Please don't forget the tests!
None sorry.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem