Mike
Implementing Content Security Policy Headers
Hello, im trying to implement CSP headers, i did manage to do it for most part but could not setup nonces for livewire.js and other scripts at the footer like notifications.js etc. I understand the team discussed this and decided not to implement it due to slowing down development efforts but i believe this deserves a second discussion.
I propose that at the very least offer the ability to set nonces for these footer scripts. As it stands right now(corrent me if wrong), these asses get 'compiled' into public director under random filenames. If we had an option to add nonces this would be very helpful as it offers the ability for developers to decide on either implementing it or not, considering the issues that may come!
Plus, i have seen companies skip using filament due to the fact that CSP headers are so hard to be setup.
Thank you
38 replies
Repeater form, getting current element index?
Im using a repeater to show three forms, one element of the form is a select field. What i need is to autoset the select value based on the repeater index eg:
0 - News
1 - Blog
Etc..
I did a lot of research and tried many things but the issue is that the repeater fields are uuid and not numbers.
So getting $get('../../repeaters') produces a bunch of element uuids
3 replies
Viewfield not updating state
I'm using tiptap editor as it fits my needs. I created a hintAction in order to display a content preview modal. The issue is that the viewfileld data does not update the state when 'content' data is changed. Code as per below:
TiptapEditor::make('content')
->required()
->disk('s3')
->live()
->afterStateUpdated(function (Forms\Get $get, Set $set) {
$set('post_content', $get('content'));
})
->hintAction(
Forms\Components\Actions\Action::make('preview')
->label('Preview Post')
->icon('heroicon-s-eye')
->form([
PreviewPost::make('post_content')
->label('')
->live()
->viewData([
'post_content' => $form->model->content
]),
])
->modalSubmitAction(false)
->modalCancelActionLabel('Close')
)
There might be a better solution to mine but this is what i could come up with8 replies
upload to s3 with thumbnails driving me nuts on filament side
So i need to upload a image to s3, all good, but i also need to upload the same image but thumbnail size. I got this working but the issue is that if i dont specify s3 disk i dont get file previews but also im unable to copy the file for thumbnail generation as its a temporary livewire file. I tried events, handle before create etc, driving me nuts.
How can i override the s3 upload process while being able to copy the file
Any help is appressiated
8 replies
S3 image upload not getting full url?
I have a fileupload field called featured_image. Im uploading the files to s3 disk, all good with that however the content saved to the database is just the file name saved into s3 and not the full url, so in this case previews dont work etc. I also have tiptap plugin installed which works all good.
What am i missing? Thank you
FileUpload::make('meta_image')
->label('Featured image')
->image()
->disk('s3')
->directory('images/posts')
->visibility('public')
->maxSize(2048)
->required(),
My s3 filesystem config:
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
17 replies
Custom view OTP input not working(no js execution)?
I'm trying to add the following tailwind otp input into a custom page view but the javascript part is not running https://flowbite.com/docs/forms/number-input/#pin-code-input
This is my code, i have tried a lot of version but none works. Funnily i had no issues with other js i added in the view. Any help appreciated.
Edit: The issue happens because this is a secondary form after the initial so i suppose livewire is not running the JS code. I even tried livewire:load as below:
@push('scripts')
<script>
document.addEventListener('livewire:load', function () {
function focusNextInput(el, prevId, nextId) {
if (el.value.length === 0) {
if (prevId) {
document.getElementById(prevId).focus();
}
} else {
if (nextId) {
document.getElementById(nextId).focus();
}
}
}
document.querySelectorAll('[data-focus-input-init]').forEach(function (element) {
element.addEventListener('keyup', function () {
const prevId = this.getAttribute('data-focus-input-prev');
const nextId = this.getAttribute('data-focus-input-next');
focusNextInput(this, prevId, nextId);
// const code = Array.from(document.querySelectorAll('[data-focus-input-init]'))
// .map(input => input.value)
// .join('');
//
// document.querySelector('[wire:model="confirmationCode"]').value = code;
});
});
});
</script>
@endpush
3 replies
how to hide wizard back button?
I have a wizard with three steps, once user goes to the third step the post is created. I dont want to allow the user to go back, and forward again as that will create another post and confuse them. Is this possible to do?
Also, is it possible to change the next button text on step 2, from next to create (not final step)
4 replies
Setting default user role when registering account?
I'm tasked on allowing normal users to register to the panel, alongside normal users there are admin accounts too. I'm using spatie roles and persmissions for managing user roles. I searched everywhere and seems there is no way to directly handle user registration in order to set a default user role, i really need access to registration process as i also have other first i need to take care of. As far as i have seen, the only way to sort of manage to do so is using model events, which is eh not good not bad
4 replies