Lovins
Lovins
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
I've been trying to solve this problem for a few hours. I've tried all the richtext plugins in the filament marketplace, all with the same problem. 😔
10 replies
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
@awcodes These are the codes
10 replies
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\QuestionResource\Pages;
use App\Filament\Resources\QuestionResource\RelationManagers;
use App\Models\Question;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Forms\Components\TagsInput;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use App\Enums\QuestionFieldEnum;
use Filament\Tables\Columns\ToggleColumn;

class QuestionResource extends Resource
{
protected static ?string $model = Question::class;

protected static ?string $navigationIcon = 'heroicon-o-question-mark-circle';

protected static ?string $navigationLabel = 'Questões';

public static ?string $label = 'Questões';

protected static ?string $recordTitleAttribute = 'question';

public static function getGloballySearchableAttributes(): array
{
return ['question', 'type', 'text', 'content'];
}

public static function getNavigationBadge(): ?string
{
return static::getModel()::count();
}

public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
Forms\Components\TextInput::make('question')
->label('Questão')
->required()
->maxLength(255),
Forms\Components\Textarea::make('text')
->label('Texto'),
Forms\Components\Select::make('type')
->label('Tipo')
->options(collect(QuestionFieldEnum::cases())->mapWithKeys(fn($case) => [$case->value => $case->getLabel()]))
->native(false)
->searchable()
->reactive()
->required()
->default('text_input'),
Forms\Components\TagsInput::make('options')
->visible(fn(callable $get) => $get('type') === 'select')
->required(fn(callable $get) => $get('type') === 'select')
->label('Opções'),
Forms\Components\RichEditor::make('content')
->visible(fn(callable $get) => $get('type') === 'defined_text')
->required(fn(callable $get) => $get('type') === 'defined_text')
->label('Conteúdo'),
Forms\Components\TextInput::make('min')
->label('Mínimo')
->numeric(),
Forms\Components\TextInput::make('max')
->label('Máximo')
->numeric(),
Forms\Components\Toggle::make('prompt')
->label('Enviar para o prompt?')
->default(false),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ManageQuestions::route('/'),
];
}
}
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\QuestionResource\Pages;
use App\Filament\Resources\QuestionResource\RelationManagers;
use App\Models\Question;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Forms\Components\TagsInput;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use App\Enums\QuestionFieldEnum;
use Filament\Tables\Columns\ToggleColumn;

class QuestionResource extends Resource
{
protected static ?string $model = Question::class;

protected static ?string $navigationIcon = 'heroicon-o-question-mark-circle';

protected static ?string $navigationLabel = 'Questões';

public static ?string $label = 'Questões';

protected static ?string $recordTitleAttribute = 'question';

public static function getGloballySearchableAttributes(): array
{
return ['question', 'type', 'text', 'content'];
}

public static function getNavigationBadge(): ?string
{
return static::getModel()::count();
}

public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
Forms\Components\TextInput::make('question')
->label('Questão')
->required()
->maxLength(255),
Forms\Components\Textarea::make('text')
->label('Texto'),
Forms\Components\Select::make('type')
->label('Tipo')
->options(collect(QuestionFieldEnum::cases())->mapWithKeys(fn($case) => [$case->value => $case->getLabel()]))
->native(false)
->searchable()
->reactive()
->required()
->default('text_input'),
Forms\Components\TagsInput::make('options')
->visible(fn(callable $get) => $get('type') === 'select')
->required(fn(callable $get) => $get('type') === 'select')
->label('Opções'),
Forms\Components\RichEditor::make('content')
->visible(fn(callable $get) => $get('type') === 'defined_text')
->required(fn(callable $get) => $get('type') === 'defined_text')
->label('Conteúdo'),
Forms\Components\TextInput::make('min')
->label('Mínimo')
->numeric(),
Forms\Components\TextInput::make('max')
->label('Máximo')
->numeric(),
Forms\Components\Toggle::make('prompt')
->label('Enviar para o prompt?')
->default(false),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ManageQuestions::route('/'),
];
}
}
10 replies
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
protected $fillable = ['question', 'type', 'options', 'min', 'max', 'content', 'text', 'order', 'prompt'];

protected $casts = [
'options' => 'array',
'content' => 'string',
];
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
protected $fillable = ['question', 'type', 'options', 'min', 'max', 'content', 'text', 'order', 'prompt'];

protected $casts = [
'options' => 'array',
'content' => 'string',
];
}
10 replies
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
Apparently the error only occurs when the RichText HTML has " But I still haven't been able to solve it.
10 replies
FFilament
Created by Lovins on 2/26/2025 in #❓┊help
Forbidden when edit richtext
No description
10 replies