Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem Storing Rich Text Fields and attachments with livewire #62

Open
surencool4 opened this issue Jul 11, 2021 · 2 comments
Open

Problem Storing Rich Text Fields and attachments with livewire #62

surencool4 opened this issue Jul 11, 2021 · 2 comments

Comments

@surencool4
Copy link

surencool4 commented Jul 11, 2021

create.blade.php


{{ __('Save Page') }}

    <x-slot name="content">
        <div class="mt-4">
            <x-jet-label for="title" value="{{ __('Title') }}" />
            <x-jet-input id="title" class="block mt-1 w-full" type="text" wire:model.debounce.800ms="title" />
            @error('title') <span class="error">{{ $message }}</span> @enderror
        </div>
        <div class="mt-4">
            <x-jet-label for="title" value="{{ __('Slug') }}" />
            <div class="mt-1 flex rounded-md shadow-sm">
                <span class="inline-flex dark:bg-black dark:text-white items-center px-3 rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-gray-500 text-sm">
                    {{ url('') }}
                </span>
                <input wire:model="slug" class="form-input dark:bg-black dark:text-white flex-1 block w-full rounded-none rounded-r-md  transition duration-150 ease-in-out sm:text-sm sm:leading-5" placeholder="url-slug">
            </div>
            @error('slug') <span class="error">{{ $message }}</span> @enderror
        </div>
      


        <div class="mt-4" >
            <x-jet-label for="content" value="{{ __('Content') }}" />
            <div class="rounded-md shadow-sm">
                    <div wire:ignore>
                        @trix(\App\Page::class, 'content')
                    </div>
                </div>                  

            </div>
            @error('content') <span class="error">{{ $message }}</span> @enderror
        </div>   
        
    </x-slot>

    <x-slot name="footer">
        <x-jet-secondary-button wire:click="$toggle('modalFormVisible')" wire:loading.attr="disabled">
            {{ __('Cancel') }}
        </x-jet-secondary-button>

            <x-jet-button class="ml-2" wire:click="create" wire:loading.attr="disabled">
                {{ __('Create') }}
            </x-jet-danger-button>
      
    </x-slot>
</x-jet-dialog-modal>

Livewire/Page.php
public function create()
{
$this->validate();
$this->post = Page::create($this->modelData());
$this->modalFormVisible = false;
$this->reset();
}
public function modelData()
{
return [
'title' => $this->title,
'slug' => $this->slug,
'content' => $this->content,
'page-trixFields' => request('page-trixFields'),
'attachment-post-trixFields' => request('attachment-post-trixFields')
];
}

@asadghazanfary
Copy link

asadghazanfary commented Oct 14, 2021

hi @surencool4

problem solved?

If you solve the problem, can you explain it to me?

thanks

@Majidkadi
Copy link

Hi,
I think you have an error in your code.
'attachment-post-trixFields' => request('attachment-post-trixFields')
I guess it should be 'page' like this:
'attachment-page-trixFields' => request('attachment-page-trixFields')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants