-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #6536 Split
ea_form_fieldset_open_row
form theme block (Wed…
…geSama) This PR was merged into the 4.x branch. Discussion ---------- Split `ea_form_fieldset_open_row` form theme block Split `ea_form_fieldset_open_row` with its `_label` + create `_ealabel` for inner content. Add new form template blocks for fieldset to ease template customization. Replace `fieldset_title_contents` by dedicated block that can be overridden. ================= Its add a new twig function `ea_form_ealabel` to be used like any other form function (`form_row`, `form_widget`, `form_label`, etc...) but for specific EA form part. In this PR, I only add a split for `ea_form_fieldset_open_row`, if this PR is accepted, I will split more template parts. ================= Why did I suggest that? IMO, for 3 reasons: - It use more sf Form component rendering functions. - It will make `templates/crud/form_theme.html.twig` more readable. - Make `templates/crud/form_theme.html.twig` override easier and more update proof. ================= Usage example: ```php class MyController extends AbstractCrudController { //... public function configureFields(string $pageName): iterable { return [ FormField::addFieldset('My Title') ->setFormTypeOption('block_prefix', 'foobar') ]; } //... } ``` ```twig {% extends '`@EasyAdmin`/crud/form_theme.html.twig' %} {% block foobar_ealabel %} <span>Add something before native block</span> {{ block('ea_form_fieldset_open_ealabel') }} <span>Add something after native block</span> {% endblock foobar_ealabel %} ``` Commits ------- 626be05 Split `ea_form_fieldset_open_row` with its `_label` + create `_ealabel` for inner content.
- Loading branch information
Showing
3 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Twig; | ||
|
||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
/** | ||
* @author Benjamin Georgeault <git@wedgesama.fr> | ||
*/ | ||
class FormExtension extends AbstractExtension | ||
{ | ||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction('ea_form_ealabel', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters