File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 54
54
* @method Field\Divide divide()
55
55
* @method Field\Password password($column, $label = '')
56
56
* @method Field\Decimal decimal($column, $label = '')
57
+ * @method Field\Html html($html)
57
58
*/
58
59
class Form
59
60
{
@@ -871,6 +872,7 @@ public static function registerBuiltinFields()
871
872
'timeRange ' => \Encore \Admin \Form \Field \TimeRange::class,
872
873
'url ' => \Encore \Admin \Form \Field \Url::class,
873
874
'year ' => \Encore \Admin \Form \Field \Year::class,
875
+ 'html ' => \Encore \Admin \Form \Field \Html::class,
874
876
];
875
877
876
878
foreach ($ map as $ abstract => $ class ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Encore \Admin \Form \Field ;
4
+
5
+ use Encore \Admin \Form \Field ;
6
+
7
+ class Html extends Field
8
+ {
9
+ /**
10
+ * Htmlable.
11
+ *
12
+ * @var string
13
+ */
14
+ protected $ html = '' ;
15
+
16
+ /**
17
+ * Create a new Html instance.
18
+ *
19
+ * @param mixed $html
20
+ */
21
+ public function __construct ($ html )
22
+ {
23
+ $ this ->html = $ html ;
24
+ }
25
+
26
+ /**
27
+ * Render html field.
28
+ *
29
+ * @return string
30
+ */
31
+ public function render ()
32
+ {
33
+ return <<<EOT
34
+ <div class="form-group">
35
+ <label class="col-sm-2 control-label"></label>
36
+ <div class="col-sm-6">
37
+ $ this ->html
38
+ </div>
39
+ </div>
40
+ EOT ;
41
+
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ public function testCreatePage()
34
34
->seeElement ('span[class=help-block] i[class*=fa-image] ' )
35
35
->seeInElement ('span[class=help-block] ' , '上传头像 ' )
36
36
->seeElement ("select[name='tags[]'][multiple=multiple] " )
37
- ->dontSeeElement ('a[class*=item_delete] ' );
37
+ ->dontSeeElement ('a[class*=item_delete] ' )
38
+ ->seeInElement ('a[html-field] ' , 'html... ' );
38
39
}
39
40
40
41
public function testSubmitForm ()
Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ protected function form()
146
146
147
147
$ form ->display ('created_at ' , 'Created At ' );
148
148
$ form ->display ('updated_at ' , 'Updated At ' );
149
+
150
+ $ form ->html ('<a html-field>html...</a> ' );
149
151
});
150
152
}
151
153
}
You can’t perform that action at this time.
0 commit comments