prodigious/sonata-permission-bundle
A Symfony bundle that adds configurable role-based permission handling to Sonata Admin, letting you restrict access to admin sections, routes, and actions for finer-grained authorization. It helps keep Sonata backends secure by aligning admin access with your application's permission model.
composer require and publish the package assets — most Laravel form/field packages ship config, migrations, and Blade views in one command (php artisan vendor:publish --provider="..."). Publish and commit the config before writing any field definitions so later minor upgrades don't silently change defaults under you.multiple_choice as an option on a field, not a new field type — so the place to read is wherever existing options (labels, required flags, help text) are set, plus the renderer that maps option values to markup.multiple_choice to the appropriate mode, drop it into a Blade form, and confirm the submitted payload shape before wiring up persistence.Start with one field end-to-end (definition → render → validate → store → re-render on edit) before templating other forms; the option only pays off once the round-trip is proven.
Treat multiple_choice as a contract between renderer and validator, not just a display toggle. The three places that must agree:
required|string|in:... for a single selection, required|array|min:1 plus array.* for multiple.array cast) for checkboxes.Derive the last two from the option rather than duplicating literals:
$isMulti = $field->option('multiple_choice') === 'checkbox';
$rules = $isMulti
? ['answers.'.$key => ['required', 'array', 'min:1'], 'answers.'.$key.'.*' => ['string', Rule::in($options)]]
: ['answers.'.$key => ['required', 'string', Rule::in($options)]];
Centralise the mode. If the option can be edited after responses exist, resolve it in one accessor/helper and read it everywhere. Scattered string comparisons on 'checkbox' are where inconsistent behaviour creeps in.
Editing existing records. Hydrate from storage into the renderer: cast JSON back to an array for multi, wrap the scalar in an array for the view's checked/selected comparison, so a single Blade partial can serve both modes.
Integration tips. For Livewire/Alpine, bind to an array in both modes (single-select simply keeps one element) to avoid the scalar↔array branch in the component. For API/Inertia surfaces, normalise the output to an array in resources and let the client decide how to present it.
required behaves differently for arrays vs scalars — an empty array fails required, but so does a missing key, and the error message is unhelpful. Add a min:1 and a custom message.multiple_choice resolves to. If it defaults to radio, fields that previously accepted multiple values will start rejecting them. Diff the published config before deploying.php artisan view:clear); stale compiled views are the usual cause of "the option has no effect".(array) $value) rather than writing a migration that guesses.in_array($option, $value, true) with string cast values; loose comparison makes "0" and empty-string options match unexpectedly.id prevents duplicate-for label clicks selecting the wrong input in repeated/nested field groups.How can I help you explore Laravel packages today?