Skip to content

Commit 20ffb05

Browse files
committed
Update Form
1 parent dc3d357 commit 20ffb05

File tree

3 files changed

+20
-49
lines changed

3 files changed

+20
-49
lines changed

src/Form/UserForm.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ protected function addElements()
115115
$this->add([
116116
'type' => 'text',
117117
'name' => 'email',
118+
'attributes' => [
119+
'class' => 'form-control',
120+
'placeholder' => 'name@example.com'
121+
],
118122
'options' => [
119123
'label' => 'E-mail',
120124
],
@@ -124,6 +128,10 @@ protected function addElements()
124128
$this->add([
125129
'type' => 'text',
126130
'name' => 'full_name',
131+
'attributes' => [
132+
'class' => 'form-control',
133+
'placeholder' => 'John Doe'
134+
],
127135
'options' => [
128136
'label' => 'Full Name',
129137
],
@@ -135,6 +143,9 @@ protected function addElements()
135143
$this->add([
136144
'type' => 'password',
137145
'name' => 'password',
146+
'attributes' => [
147+
'class' => 'form-control'
148+
],
138149
'options' => [
139150
'label' => 'Password',
140151
],
@@ -144,6 +155,9 @@ protected function addElements()
144155
$this->add([
145156
'type' => 'password',
146157
'name' => 'confirm_password',
158+
'attributes' => [
159+
'class' => 'form-control'
160+
],
147161
'options' => [
148162
'label' => 'Confirm password',
149163
],
@@ -154,21 +168,24 @@ protected function addElements()
154168
$this->add([
155169
'type' => 'select',
156170
'name' => 'role',
157-
158171
'options' => [
159172
'label' => 'Role',
160173
'value_options' => $this->rolesselector,
161174

162175
],
163176
'attributes' => [
164177
'value' => $this->rolecurrent,
178+
'class' => 'form-control'
165179
]
166180
]);
167181

168182
// Add "status" field
169183
$this->add([
170184
'type' => 'select',
171185
'name' => 'status',
186+
'attributes' => [
187+
'class' => 'form-control'
188+
],
172189
'options' => [
173190
'label' => 'Status',
174191
'value_options' => [
@@ -183,7 +200,8 @@ protected function addElements()
183200
'type' => 'submit',
184201
'name' => 'submit',
185202
'attributes' => [
186-
'value' => 'Create'
203+
'value' => 'Create',
204+
'class' => 'btn btn-primary'
187205
],
188206
]);
189207
}

view/user/user/add.phtml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,6 @@ $this->pageBreadcrumbs()->setItems([
99
'Add User'=>$this->url('users', ['action'=>'add'])
1010
]);
1111

12-
$form->get('email')->setAttributes([
13-
'class'=>'form-control',
14-
'placeholder'=>'name@example.com'
15-
]);
16-
17-
$form->get('full_name')->setAttributes([
18-
'class'=>'form-control',
19-
'placeholder'=>'John Doe'
20-
]);
21-
22-
$form->get('role')->setAttributes([
23-
'class'=>'form-control'
24-
]);
25-
26-
$form->get('status')->setAttributes([
27-
'class'=>'form-control'
28-
]);
29-
30-
$form->get('password')->setAttributes([
31-
'class'=>'form-control'
32-
]);
33-
34-
$form->get('confirm_password')->setAttributes([
35-
'class'=>'form-control'
36-
]);
37-
38-
$form->get('submit')->setAttributes(['class'=>'btn btn-primary']);
39-
4012
$form->prepare();
4113
?>
4214

view/user/user/edit.phtml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,7 @@ $this->pageBreadcrumbs()->setItems([
99
'Edit User'=>$this->url('users', ['action'=>'edit', 'id'=>$user->getId()])
1010
]);
1111

12-
$form->get('email')->setAttributes([
13-
'class'=>'form-control',
14-
'placeholder'=>'name@example.com'
15-
]);
16-
17-
$form->get('full_name')->setAttributes([
18-
'class'=>'form-control',
19-
'placeholder'=>'John Doe'
20-
]);
21-
22-
$form->get('role')->setAttributes([
23-
'class'=>'form-control'
24-
]);
25-
26-
$form->get('status')->setAttributes([
27-
'class'=>'form-control'
28-
]);
29-
3012
$form->get('submit')
31-
->setAttributes(['class'=>'btn btn-primary'])
3213
->setValue('Save');
3314

3415
$form->prepare();

0 commit comments

Comments
 (0)