/
ContentElementForm.php
37 lines (30 loc) · 1.11 KB
/
ContentElementForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace Johncms\Content\Forms;
use Johncms\Forms\AbstractForm;
use Johncms\Forms\Inputs\InputText;
use Johncms\Forms\Inputs\Textarea;
class ContentElementForm extends AbstractForm
{
protected function prepareFormFields(): array
{
$fields = [];
$fields['name'] = (new InputText())
->setLabel(__('Name'))
->setPlaceholder(p__('placeholder', 'Enter the Name of the Element'))
->setNameAndId('name')
->setValue($this->getValue('name'))
->setValidationRules(['NotEmpty']);
$fields['code'] = (new InputText())
->setLabel(__('Code'))
->setPlaceholder(p__('placeholder', 'Enter the Code of the Element'))
->setNameAndId('code')
->setValue($this->getValue('code'));
$fields['detail_text'] = (new Textarea())
->setLabel(__('Detail Text'))
->setPlaceholder(p__('placeholder', 'Enter the Detail Text'))
->setNameAndId('detail_text')
->setValue($this->getValue('detail_text'));
return $fields;
}
}