github-bishwajeet/laravel-nova-conditional-container
A Laravel Nova field that wraps other fields in a container you can show or hide based on the values of other fields, keeping complex forms tidy and dynamic without writing custom JavaScript. Configure simple conditions to control visibility.
Start by installing the package with Composer and checking the package README for the exact condition/container API exposed by your version:
composer require github-bishwajeet/laravel-nova-conditional-container
After install, look first at:
ConditionalContainer import path and condition methods.If the package publishes assets, run the documented publish command and then clear Nova/cache:
php artisan vendor:publish --tag=laravel-nova-conditional-container
php artisan nova:publish
php artisan optimize:clear
The first practical use case is section-level visibility: show a “Billing Address” group only when billing_same_as_shipping is false, or show “Advanced Settings” only when a plan/status select reaches a certain value.
use GithubBishwajeet\LaravelNovaConditionalContainer\ConditionalContainer;
ConditionalContainer::make('Billing Address')
->dependsOn('billing_same_as_shipping', false) // confirm exact method in README
->fields([
Text::make('Address'),
Text::make('City'),
Text::make('Postal Code'),
]),
Keep the first implementation narrow: one boolean/select condition, two or three fields, and test create/update flows before rolling it out to larger resources.
Use the package as a form-layout and visibility tool, not as your validation or authorization layer. The strongest day-to-day patterns are:
Boolean, Select, or similar Nova field.Text::make('VAT Number')
->rules('required_if:is_business,true'),
plan is enterprise, or show “Refund Details” only after status becomes refunded.A typical resource pattern:
public function fields(NovaRequest $request)
{
return [
Boolean::make('Billing Same As Shipping', 'billing_same_as_shipping')
->default(true),
ConditionalContainer::make('Billing Address')
->dependsOn('billing_same_as_shipping', false) // use documented API
->fields([
Text::make('Billing Address', 'billing_address')
->rules('required_if:billing_same_as_shipping,false'),
Text::make('Billing City', 'billing_city')
->rules('required_if:billing_same_as_shipping,false'),
]),
];
}
sometimes/nullable/required_if rules deliberately.php artisan optimize:clear / php artisan nova:publish. Stale compiled assets are a common source of “nothing changed” confusion.canSee callbacks.How can I help you explore Laravel packages today?