moussaclarke
moussaclarke
TCTwill CMS
Created by moussaclarke on 11/20/2024 in #👊support
Validate file uploads in block in Twill 3
thanks @ifox I will take a look. is this the pr in question? https://github.com/area17/twill/pull/2638
5 replies
TCTwill CMS
Created by moussaclarke on 11/20/2024 in #👊support
Validate file uploads in block in Twill 3
Medias payload in devtools looks correct as far as I can see:
{
"file[fr]": [
{
"id": 123,
"name": "75b035b4-1a09-4f43-aee3-7228db412713_BP-F2.PDF",
"src": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"original": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bfp-f2.pdf",
"size": "1.02 Mb",
"filesizeInMb": "1.02",
"pivot_id": 2614
}
],
"file[en]": [
{
"id": 123,
"name": "75b035b4-1a09-4f43-aee3-7228db412713_BP-F2.PDF",
"src": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"original": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"size": "1.02 Mb",
"filesizeInMb": "1.02",
"tags": [],
"deleteUrl": null,
"updateUrl": "https://example.test/admin/file-library/files/single-update",
"updateBulkUrl": "https://example.test/dashboard/file-library/files/bulk-update",
"deleteBulkUrl": "https://example.test/dashboard/file-library/files/bulk-delete",
"disabled": false
}
]
}
{
"file[fr]": [
{
"id": 123,
"name": "75b035b4-1a09-4f43-aee3-7228db412713_BP-F2.PDF",
"src": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"original": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bfp-f2.pdf",
"size": "1.02 Mb",
"filesizeInMb": "1.02",
"pivot_id": 2614
}
],
"file[en]": [
{
"id": 123,
"name": "75b035b4-1a09-4f43-aee3-7228db412713_BP-F2.PDF",
"src": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"original": "https://example.com/8843d7f92416211de9ebb963ff4ce28125932878/75b035b4-1a09-4f43-aee3-7228db412713-bp-f2.pdf",
"size": "1.02 Mb",
"filesizeInMb": "1.02",
"tags": [],
"deleteUrl": null,
"updateUrl": "https://example.test/admin/file-library/files/single-update",
"updateBulkUrl": "https://example.test/dashboard/file-library/files/bulk-update",
"deleteBulkUrl": "https://example.test/dashboard/file-library/files/bulk-delete",
"disabled": false
}
]
}
5 replies
TCTwill CMS
Created by moussaclarke on 9/3/2024 in #👊support
Automatically make languages live/remove user control
In case this helps anyone here is the code for my solution. And if anyone knows of a better/cleaner way please comment 👍
// in AppServiceProvider boot() method
View::share('controlLanguagesPublication', false);

// in relevant model repositories - I used a trait as I needed it in all of them
public function prepareFieldsBeforeCreate($fields): array
{
foreach ($fields['languages'] as $key => $language) {
$fields['languages'][$key]['published'] = true;
}

return parent::prepareFieldsBeforeCreate($fields); // @phpstan-ignore-line
}
// in AppServiceProvider boot() method
View::share('controlLanguagesPublication', false);

// in relevant model repositories - I used a trait as I needed it in all of them
public function prepareFieldsBeforeCreate($fields): array
{
foreach ($fields['languages'] as $key => $language) {
$fields['languages'][$key]['published'] = true;
}

return parent::prepareFieldsBeforeCreate($fields); // @phpstan-ignore-line
}
3 replies
TCTwill CMS
Created by moussaclarke on 9/3/2024 in #👊support
Automatically make languages live/remove user control
For selecting all languages as active automatically I've wound up with some logic in prepareFieldsBeforeCreate on all repositories.
3 replies