1
|
|
|
<?php namespace Anomaly\Streams\Platform\Assignment\Form; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class AssignmentFormFields |
5
|
|
|
* |
6
|
|
|
* @link http://anomaly.is/streams-platform |
7
|
|
|
* @author AnomalyLabs, Inc. <[email protected]> |
8
|
|
|
* @author Ryan Thompson <[email protected]> |
9
|
|
|
* @package Anomaly\Streams\Platform\Assignment\Form |
10
|
|
|
*/ |
11
|
|
|
class AssignmentFormFields |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Handle the form fields. |
16
|
|
|
* |
17
|
|
|
* @param AssignmentFormBuilder $builder |
18
|
|
|
*/ |
19
|
|
|
public function handle(AssignmentFormBuilder $builder) |
20
|
|
|
{ |
21
|
|
|
$builder->setFields( |
22
|
|
|
[ |
23
|
|
|
'label' => [ |
24
|
|
|
'label' => 'streams::assignment.label.name', |
25
|
|
|
'instructions' => 'streams::assignment.label.instructions', |
26
|
|
|
'type' => 'anomaly.field_type.text' |
27
|
|
|
], |
28
|
|
|
'placeholder' => [ |
29
|
|
|
'label' => 'streams::assignment.placeholder.name', |
30
|
|
|
'instructions' => 'streams::assignment.placeholder.instructions', |
31
|
|
|
'type' => 'anomaly.field_type.text' |
32
|
|
|
], |
33
|
|
|
'instructions' => [ |
34
|
|
|
'label' => 'streams::assignment.instructions.name', |
35
|
|
|
'instructions' => 'streams::assignment.instructions.instructions', |
36
|
|
|
'type' => 'anomaly.field_type.textarea' |
37
|
|
|
], |
38
|
|
|
'warning' => [ |
39
|
|
|
'label' => 'streams::assignment.warning.name', |
40
|
|
|
'instructions' => 'streams::assignment.warning.instructions', |
41
|
|
|
'type' => 'anomaly.field_type.text' |
42
|
|
|
], |
43
|
|
|
'required' => [ |
44
|
|
|
'label' => 'streams::assignment.required.label', |
45
|
|
|
'instructions' => 'streams::assignment.required.instructions', |
46
|
|
|
'type' => 'anomaly.field_type.boolean' |
47
|
|
|
], |
48
|
|
|
'unique' => [ |
49
|
|
|
'label' => 'streams::assignment.unique.label', |
50
|
|
|
'instructions' => 'streams::assignment.unique.instructions', |
51
|
|
|
'type' => 'anomaly.field_type.boolean' |
52
|
|
|
], |
53
|
|
|
'translatable' => [ |
54
|
|
|
'label' => 'streams::assignment.translatable.label', |
55
|
|
|
'instructions' => 'streams::assignment.translatable.instructions', |
56
|
|
|
'type' => 'anomaly.field_type.boolean', |
57
|
|
|
'warning' => function (AssignmentFormBuilder $builder) { |
58
|
|
|
|
59
|
|
|
$type = $builder->getFieldType(); |
60
|
|
|
|
61
|
|
|
return $type->getColumnType() == null ? 'streams::assignment.translatable.warning' : null; |
62
|
|
|
}, |
63
|
|
|
'disabled' => function (AssignmentFormBuilder $builder) { |
64
|
|
|
|
65
|
|
|
$stream = $builder->getStream(); |
66
|
|
|
|
67
|
|
|
if ($stream && !$stream->isTranslatable()) { |
68
|
|
|
return true; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$type = $builder->getFieldType(); |
72
|
|
|
|
73
|
|
|
return $type->getColumnType() == null; |
74
|
|
|
} |
75
|
|
|
] |
76
|
|
|
] |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|