Installation
composer require clubmaster/formextra
Bundle Registration
Add to config/bundles.php (Symfony 4+):
Club\FormExtraBundle\ClubFormExtraBundle::class => ['all' => true],
(For Symfony 3.x, add to AppKernel.php as per the README.)
Twig Integration
{% form_theme form '@ClubFormExtra/Default/fields.html.twig' %}
{% form_theme form '@ClubFormExtra/Default/fields.html.twig' %}
First Use Case: Enhanced Textarea
{{ form_widget(form.description, {'attr': {'class': 'tinymce'}}) }}
(Note: Add novalidate="true" to the <form> tag for TinyMCE.)
Slider Integration Use the built-in slideshow for static content:
<ul id="slideshow">
{% for item in items %}
<li>{{ item }}</li>
{% endfor %}
</ul>
{{ include('@ClubFormExtra/Default/slideshow.html.twig') }}
(Include slideshow.css and slideshow.js in your layout.)
Typeahead Autocomplete Controller Setup:
public function autocompleteAction(Request $request)
{
$results = [
['value' => 'Option 1', 'label' => 'Label 1'],
['value' => 'Option 2', 'label' => 'Label 2'],
];
return new JsonResponse($results);
}
Twig Template:
{{ form_widget(form.search, {
'attr': {
'data-url': path('app_autocomplete'),
'class': 'typeahead'
}
}) }}
(Include typeahead.css, handlebars.js, and typeahead.bundle.js.)
Dynamic Form Theming
Override default templates in templates/bundles/ClubFormExtra/Default/ to customize fields (e.g., textarea_widget.html.twig for TinyMCE).
Validation Handling Disable validation for TinyMCE fields:
<form {{ form_enctype(form) }} method="{{ form_method(form) }}" novalidate>
Asset Management Use Symfony’s asset pipeline for CSS/JS:
<link rel="stylesheet" href="{{ asset('bundles/clubformextra/css/typeahead.css') }}">
| Feature | Implementation | Notes |
|---|---|---|
| Rich Textarea | class="tinymce" + novalidate |
Requires TinyMCE setup (not bundled). |
| Slideshow | Include slideshow.html.twig + assets |
Static content only. |
| Typeahead | data-url + JSON endpoint |
Customize templates via Handlebars. |
TinyMCE Dependencies
tinymce/tinymce).novalidate="true" to forms with TinyMCE fields to avoid validation conflicts.Typeahead JSON Structure
{'value': '...', 'label': '...'} for typeahead.Asset Paths
bundles/clubformextra/js/slideshow.css) may break if assets aren’t published.asset() function or configure asset paths in config/packages/assetic.yaml.Twig Template Overrides
ClubFormExtra/Default/ directory in your templates/bundles/ folder.debug: true in config/packages/twig.yaml to verify template inheritance.twig:
debug: true
curl or Postman to ensure correct JSON format:
curl -X GET http://your-app.com/autocomplete
slideshow.js). Use the Network tab to verify paths.Custom Handlebars Templates
Override typeahead.html.twig to modify the autocomplete UI:
{# templates/bundles/ClubFormExtra/Default/typeahead.html.twig #}
<div class="custom-typeahead">
{{ parent() }}
</div>
Add New Field Types Extend the bundle by creating custom Twig extensions or form types in your application bundle.
Configuration No public config options exist, but you can override assets or templates via Symfony’s template inheritance.
{% form_theme form [
'@ClubFormExtra/Default/fields.html.twig',
'form/themes/default.html.twig' # Symfony fallback
] %}
{{ asset('bundles/clubformextra/css/slideshow.css', 'clubformextra') }}
How can I help you explore Laravel packages today?