1. Go to this page and download the library: Download phloxcz/forms-editor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phloxcz / forms-editor example snippets
protected function createComponentArticleForm(): Form
{
$form = new Form;
$form->addText('title', 'Nadpis');
$form->addEditor('content', 'Obsah článku')
->setUploadRoute($this->link('Article:wysiwygUpload'))
->setRequired('Zadejte obsah.');
$form->addSubmit('save', 'Uložit');
$form->onSuccess[] = [$this, 'formSucceeded'];
return $form;
}
public function formSucceeded(Form $form, \stdClass $values): void
{
// ⚠️ Vždy sanitizujte HTML před uložením!
$safe = $this->htmlPurifier->purify($values->content);
$this->articles->save(['title' => $values->title, 'content' => $safe]);
$this->redirect('this');
}