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

Unable to set value of CkEditor programmatically #130

Open
webard opened this issue Jun 4, 2024 · 0 comments
Open

Unable to set value of CkEditor programmatically #130

webard opened this issue Jun 4, 2024 · 0 comments

Comments

@webard
Copy link

webard commented Jun 4, 2024

Hello,

firstly, thank you for great package.

I noticed problem, when I try to programmatically set value of CkEditor field, nothing changes. Dynamic values are useful when we have predefined HTML templated which can be inserted directly to editor end modified by admin.

Select::make('Template', 'template')
->options([
    '1' => 'Template 1',
    '2' => 'Template 2',
]),

CkEditor::make('Notes', 'notes')
    ->rules('required')
    ->dependsOn(['template'], function (CkEditor $field, NovaRequest $request, FormData $formData) {

        $tpl = $formData->get('template');

        if ($tpl === '1') {

            $field->setValue('<h1>Template 1</h1>');
        }
    })
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

1 participant