Update code of third part of tutorial series
[GitHub/WoltLab/woltlab.github.io.git] / snippets / tutorial / tutorial-series / part-3 / files / lib / acp / form / PersonAddForm.class.php
1 <?php
2
3 namespace wcf\acp\form;
4
5 use wcf\data\person\PersonAction;
6 use wcf\form\AbstractFormBuilderForm;
7 use wcf\system\form\builder\container\FormContainer;
8 use wcf\system\form\builder\field\BooleanFormField;
9 use wcf\system\form\builder\field\TextFormField;
10
11 /**
12 * Shows the form to create a new person.
13 *
14 * @author Matthias Schmidt
15 * @copyright 2001-2021 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\Acp\Form
18 */
19 class PersonAddForm extends AbstractFormBuilderForm
20 {
21 /**
22 * @inheritDoc
23 */
24 public $activeMenuItem = 'wcf.acp.menu.link.person.add';
25
26 /**
27 * @inheritDoc
28 */
29 public $formAction = 'create';
30
31 /**
32 * @inheritDoc
33 */
34 public $neededPermissions = ['admin.content.canManagePeople'];
35
36 /**
37 * @inheritDoc
38 */
39 public $objectActionClass = PersonAction::class;
40
41 /**
42 * @inheritDoc
43 */
44 public $objectEditLinkController = PersonEditForm::class;
45
46 /**
47 * @inheritDoc
48 */
49 public function createForm()
50 {
51 parent::createForm();
52
53 $this->form->appendChild(
54 FormContainer::create('data')
55 ->label('wcf.global.form.data')
56 ->appendChildren([
57 TextFormField::create('firstName')
58 ->label('wcf.person.firstName')
59 ->required()
60 ->autoFocus()
61 ->maximumLength(255),
62
63 TextFormField::create('lastName')
64 ->label('wcf.person.lastName')
65 ->required()
66 ->maximumLength(255),
67
68 BooleanFormField::create('enableComments')
69 ->label('wcf.person.enableComments')
70 ->description('wcf.person.enableComments.description')
71 ->value(true),
72 ])
73 );
74 }
75 }