Merge branch 'fixdynamicpageslugvalidationpattern' into 'develop'

fix: 🐛 dynamic slug pattern accept int, simpleswitch label are added

See merge request ldc-web/projets/ldc!63
This commit is contained in:
karl.muller 2025-11-21 08:16:07 +00:00
commit 1c0dbc801f
4 changed files with 5 additions and 10 deletions

View file

@ -50,7 +50,7 @@ class StoreDynamicPageRequest extends UpdateDynamicFieldRequest
{
$rules = [
'title' => 'required|string|between:3,255',
'slug' => 'required|string|regex:/^[-A-Za-z]{3,255}$/',
'slug' => 'required|string|regex:/^[-A-Za-z0-9]{3,255}$/',
'page_id' => 'sometimes|nullable|numeric|exists:dynamic_pages,id',
'config_id' => 'sometimes|nullable|numeric|exists:page_configs,id',
'status' => ['required', new Enum(PageStatusEnum::class)],

View file

@ -128,13 +128,8 @@ export default function DynamicInputs({
case enumDynamicFieldTypes.boolean.value:
return (
<div key={id} className="grid grid-cols-1 gap-1.5">
<label
htmlFor={`#${fieldName}`}
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
{`${getTrans(field.label)} ${extractRequiredValidation(field.validation) ? " *" : ""}`}
</label>
<SimpleSwitch
label={`${getTrans(field.label)} ${extractRequiredValidation(field.validation) ? " *" : ""}`}
name={fieldName}
checked={Boolean(fieldValue)}
setData={setData}

View file

@ -10,7 +10,7 @@ import { Label } from "@/components/ui/label";
type SimpleSwitchProps = {
name: string;
checked?: boolean;
label: string;
label?: string;
leftHelper?: string;
rightHelper?: string;
required?: boolean;
@ -36,7 +36,7 @@ export default function SimpleSwitch({
return (
<div className="flex flex-col items-start w-fit gap-1.5">
<Label htmlFor={name}>{label + (required ? " *" : "")}</Label>
{label && (<Label htmlFor={name}>{label + (required ? " *" : "")}</Label>)}
<div className="flex items-center gap-3">
{leftHelper && (
<small>{leftHelper}</small>

View file

@ -317,7 +317,7 @@ export default function Form({
.value()}
wordCounter={false}
value={data.slug}
pattern="[a-z\-]{3,255}"
pattern="[a-z0-9\-]{3,255}"
setData={setData}
/>
<div className="col-span-1 md:col-span-2">