Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Ordered Form

Ordered Form Laravel Package

egeloen/ordered-form

Symfony2 form extension that lets you control field order via a "position" option. Place fields first, last, or relative to others using before/after rules for predictable, readable form layouts.

View on GitHub
Deep Wiki
Context7

Provides a form ordering support with the Symfony2 form component.

Frequently asked questions about Ordered Form
Can I use egeloen/ordered-form directly in Laravel without Symfony?
No, this package requires Symfony’s Form component. You’ll need to bridge Laravel’s form system (e.g., `Form::macro` or `FormRequest`) with Symfony’s `FormFactory` via a custom adapter or a package like `laravel-symfony`. Start with a proof-of-concept service provider to test compatibility.
What Laravel versions support this package?
The package itself targets Symfony 5.x+, so Laravel 8.x+ is recommended (PHP 8.0+). Older Laravel versions may need additional polyfills or Symfony version adjustments. Test thoroughly with your specific Laravel release, as form handling differs across versions.
How do I define field ordering in Laravel using this package?
Use the `position` option (e.g., `['position' => 'first']`) or associative arrays for `before`/`after` rules, just like Symfony. Example: `$builder->add('name', TextType::class, ['position' => ['before' => 'email']])`. Wrap the Symfony `FormBuilder` in a Laravel service to apply these rules.
Will this work with Laravel Livewire or Inertia.js forms?
Yes, but ordering logic must be applied server-side. Livewire/Inertia forms still rely on Laravel’s form rendering pipeline. Use the package’s Symfony integration in your backend, then pass the ordered fields to the frontend. Client-side JS can’t override server-side ordering rules.
Are there conflicts if Laravel already uses Symfony components?
Potential conflicts may arise if Laravel or other packages use a different Symfony version. Lock dependencies in `composer.json` (e.g., `symfony/form:^5.4`) and test for version compatibility. Use `composer why symfony/form` to audit dependencies.
How do I persist form field positions for users (e.g., save preferences)?
Store positions in Laravel’s `session`, `database`, or `cache`. Example: Use a `FormPosition` model with `user_id` and `form_type` fields. Sync positions via middleware or a service that injects the `position` option dynamically into the Symfony `FormBuilder`.
Does this package support nested forms or dynamic fields?
The package handles nested fields if they’re part of the Symfony `FormType` hierarchy, but dynamic fields (added via JavaScript) require manual reordering. Test with your specific use case—complex nested forms may need custom `FormOrderer` logic to resolve dependencies.
What’s a simpler alternative for basic field reordering in Laravel?
For simple cases, use Laravel’s `Form::macro` to sort fields manually: `Form::macro('orderFields', fn($fields) => collect($fields)->sortBy(...))`. Packages like `spatie/laravel-form-builder` also offer field management without Symfony dependencies.
How do I test form ordering logic in Laravel?
Mock the Symfony `FormFactory` and `OrderedExtension` in PHPUnit tests. Verify field order by inspecting the rendered HTML or the `FormInterface` structure. Example: `$form->createView()->children` should reflect your `position` rules. Adapt the package’s existing tests as a starting point.
What if integration fails—are there fallbacks?
If Symfony integration proves too complex, fall back to client-side JS (e.g., SortableJS) or server-side array manipulation. For critical forms, implement a hybrid approach: use the package for static ordering and JS for dynamic adjustments, with server-side validation to enforce rules.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity