antonythorpe / silverstripe-formfieldadditionalclasses
Warning: there is an error in this module as it adds classes to all form fields. Abandoned. 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.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- silverstripe/framework: ^4.0.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2022-02-27 19:40:02 UTC
README
Warning: there is an error in this module as it adds classes to all form fields. Abandoned. 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.
Why use this Silverstripe module?
For styling of Form Fields
How it works
Extends the FormField
class
Example
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>
Approach of this Module
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.
Requirements
Documentation
Pull Requests are Welcome
Feel free to send a pull request. Please don't forget the tests!
Support
None sorry.