Reputation: 13910
I'm trying to implement the old()
on a bunch of checkboxes generated by 2 foreach (one with key $day_key
and one with $period_key
)
<input type="checkbox"
name="availability[{{ $day_key }}][{{ $period_key }}]"
{{ ( old('availability["'.$day_key.'"]["'.$period_key.'"]') == 'on' ) ? 'checked' : '' }} />
I need to print this string inside the old() function:
'availability["'.$day_key.'"]["'.$period_key.'"]'
but it doesn't work. How can I do it?
Upvotes: 2
Views: 395
Reputation: 163768
The correct syntax is:
{{ old('availability')[$day_key][$period_key] === 'on' ? 'checked' : '' }}
Upvotes: 2