Farzane
Farzane
FFilament
Created by Farzane on 10/16/2024 in #❓┊help
update value
I have an issue with modifying textarea field by javascipt i wrote a function i call it on the change of a drop down and I add value of select to the textarea this function works properly and the value of select dynamically added to textarea while changing. the issue is when i submit the form i cant get the modified data in database and only data typed directly in the textarea stored in db what is the issue? Translate::make() ->locales(['fa', 'en']) ->columnSpanFull() ->columns(2) ->schema(fn (string $locale) => [ Forms\Components\Select::make('variables') ->extraAttributes([ 'onchange' => 'insertToTextarea("'.$locale.'")' ]) ->options(NotificationTemplateVariableEnums::class), Forms\Components\Textarea::make('template') ->required() ->columnSpanFull() ->reactive(), ]) function insertToTextarea(locale) { const textarea = document.getElementById('data.template.'+locale+''); const variable = document.getElementById('data.variables.'+locale+'').value; if (!textarea) return; const start = textarea.selectionStart; const end = textarea.selectionEnd; const value = textarea.value; textarea.value = value.slice(0, start) + variable + value.slice(end); textarea.selectionStart = textarea.selectionEnd = start + variable.length; textarea.focus(); }
2 replies