-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Added form tabs #1887
Added form tabs #1887
Conversation
Like the form groups tabs are another way to separate form fields to achieve a better overview. Tabs can contain groups but not the other way round. The `NormalizerConfigPass` ensures that there are no orphan fields before the first tab definition similar to the normalizing of the groups' config and it even takes care about it if tabs and groups are used together. In the Twig template the part, that is responsible for the display of groups, has been moved to a separate block to avoid code duplication.
👍 It'll be awesome, especially for translation stuff ! |
In my opinion this is useless in current realisation. In our project we use tabs for better navigation, but every tabs is a separated pages with it's own configuration in |
I thought about the validation issue. One could add a special icon to a tab, which contains violations or a label to signalize violations. |
@Naitsirch That and you should always jump to the first tab that containing a validation error. This way you'll never see a tab containing no error, looking like the submission was successful. |
I have extended the tab functionality to address the notes made by @grachevko and @iluuu1994. If there's a tab with form violations, this tab is activated. Any other objections? |
Sorry for adding another coding style fixing commit, but I couldn't get phpunit and php-cs working for this project. Executing
|
@Naitsirch don't worry! I'll take a look at tests when I review this proposal. Thanks! |
src/Form/Type/EasyAdminFormType.php
Outdated
$formTabs[$activeTab]['active'] = true; | ||
} | ||
}; | ||
$builder->addEventListener(FormEvents::POST_SUBMIT, $listenerClosure, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest add a listener class to make this EasyAdminFormType
class more understandable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ;-)
doc/book/edit-new-configuration.rst
Outdated
@@ -747,6 +747,38 @@ very advanced layouts. | |||
This solves most of the issues, but sometimes you might be forced to also | |||
reorder the form group positions. | |||
|
|||
Form Tabs | |||
........... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many dots
@fabpot Thanks for the catch. I've removed the superfluous trailing dots. |
I would like to use form tabs, can I merge this pull request into my own EasyAdmin branch? Or will this be merged sometime soon in the main EasyAdmin repo? |
@victorbstan Yes, of course you can ;-) @javiereguiluz Would be nice if you could review this one soon. |
@Naitsirch thanks a lot for contributing this feature. It was a stellar first contribution to this bundle. And to be completely honest, I would have never been able to implement this feature myself :) |
Like the form groups tabs are another way to separate form fields to achieve a better overview and a cleaner interface.
Tabs can contain groups but not the other way round. The
NormalizerConfigPass
ensures that there are no orphan fields before the first tab definition similar to the normalizing of the groups' config and it even takes care about it if tabs and groups are used together.In the Twig template the part, that is responsible for the display of groups, has been moved to a separate block to avoid code duplication.
Here's a screen shot showing how it looks like:
Tell me if there's anything bothering you so that I can fix it. I'd be happy if this PR would be merged ;-)