moussaclarke
moussaclarke
TCTwill CMS
Created by moussaclarke on 11/20/2024 in #👊support
Validate file uploads in block in Twill 3
Hi there - does anyone know what the correct syntax is to validate file uploads using twillBlockValidationRulesForTranslatedFields? I've got a translated file input for a single pdf.
<x-twill::files name="file" label="Pdf File" :max="1" :translated="true" :required="true" />
<x-twill::files name="file" label="Pdf File" :max="1" :translated="true" :required="true" />
and at the top of the file:
@twillBlockValidationRulesForTranslatedFields([
'file' => 'required|mimes:pdf'
])
@twillBlockValidationRulesForTranslatedFields([
'file' => 'required|mimes:pdf'
])
But on validation this always thinks that the file is missing e.g.
{
"blocks.1063[file][en]": [
"The file field is required."
],
"blocks.en": [
"Failed"
],
"blocks.1063[file][fr]": [
"The file field is required."
],
"blocks.fr": [
"Failed"
]
}
{
"blocks.1063[file][en]": [
"The file field is required."
],
"blocks.en": [
"Failed"
],
"blocks.1063[file][fr]": [
"The file field is required."
],
"blocks.fr": [
"Failed"
]
}
I've tried various other keys for the rule e.g. medias.file etc with similar results. What am I doing wrong? Is this not currently supported?
5 replies
TCTwill CMS
Created by moussaclarke on 9/3/2024 in #👊support
Automatically make languages live/remove user control
Use case - on a bilingual site I need to make both configured languages live by default for any item (including settings). I'd also ideally like to remove the ability for admin users to edit this at all. I've spotted a variable called $controlLanguagesPublication in the form layout which seems to hide the language active controls, and am using View::share in AppServiceProvider to globally force this to false . However this seems slightly brutal and I'm not sure if there might be any side effects. Also this doesn't solve selecting all languages as active by default (although I guess I could probably figure that out during save) Could anyone possibly confirm the best way to achieve this?
3 replies