#Why does TextInput does not want to save value

6 messages · Page 1 of 1 (latest)

stiff apex
#

Hi everyone i have a problem where mine textinput does not want to save the value i enter. This is how i made the textinput ```
public static function form(Form $form): Form
{
return $form
->schema(Project::getForm())->columns(1);
}
// admin panel form
public static function getForm():array
{
return [
Tabs::make()->schema(Project::makeTabs()),

private static function makeTabs()
{
$tabs = [];
$languages = Languages::cases();
foreach($languages as $lang)
{
$tabs[] = Tab::make(Languages::getFullName($lang->name))
->schema([
TextInput::make("contents.{$lang->value}.title")
->required()
->maxLength(50)
->afterStateHydrated(function (TextInput $component, $state, $record) use ($lang) {
if($record){
$content = $record->contents()->language($lang->value)->first();
$component->state($content->title ?? null);
}
})```

fading sinewBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

stiff apex
#

Here you can see the code in better structure

velvet rose
#

The name of the textInput = contents.{$lang->value}.title

The save will try to resolve the relation contents.[lang] right?
and save it to the title column on that relation.

Does that relation even exist in the contents model?

stiff apex
#

I have a table called project_contents and table projects, i have a relation between Project and ProjecContent public function contents(): HasMany { return $this->hasMany(ProjectContent::class, 'project_id', 'id'); }

#

And for the ProjectContent like down below i am using the scoupe so i can access the record with languages i want ```
//Relationship to Project
public function project(): BelongsTo
{
return $this->belongsTo(Project::class, 'project_id','id');
}

//Scopes
public function scopeLanguage($query, $language)
{
    return $query->where('language', $language);
}```