New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Form to be extended #3688
Comments
I've done SilverStripe with Bootstrap before, without ever needing to do a transformation on a You can override any template with relative ease; one thing I'd like to see by default is the form's subclass being looked for before falling back to using Fields, too, can be customised in this way (using Am I missing something? 😄 |
@willmorgan yes you can do that, but it would also be good if you could hook into the FormField somewhere and add classes to be all forms, perhaps through config: FormField:
extra_classes:
- 'form-control' Of course this doesn't solve the problem of the layout for a bootstrap etc. form needing to be different from the way which SS does it. We currently write every form into the template where they are used as it gives us a bit more freedom 😄 @wernerkrauss have you seen @unclecheese bootstrap module? Perhaps writing something along those lines for your own use internally would be of use? |
@stevie-mayhew I agree that there needs to be a way to inject default classes into form fields |
I'm currently working on something to add |
@willmorgan the point is: i don't want to replace existing form (like login form) or forms bundled in modules with my own subclass of Form. This just doesn't feel right for me. |
Using HTML/CSS Frameworks like Bootstrap or Foundation you have to transform the Forms to be rendered properly. A current solution is to subclass Form and do changes. This is quite un-handy when you have already some Forms (e.g. MemberLoginForm) which you also have to subclass and use instead.
The Foundation solution is quite easy and just calles some stuff in
forTemplate()
. See https://github.com/ryanwachtl/silverstripe-foundation-forms/blob/master/code/FoundationForm.phpI think it might be quite handy if at least
Form::forTemplate()
would have an extension point where you can plug in some functionality for all forms globally (you'll have to check if you're in frontend manually).The text was updated successfully, but these errors were encountered: