Completed
Push — master ( d683c1...adb78f )
by Song
17s queued 11s
created

src/Form/Field/Text.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
use Encore\Admin\Form\Field;
6
7
class Text extends Field
8
{
9
    use PlainInput;
10
11
    /**
12
     * Render this filed.
13
     *
14
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
15
     */
16
    public function render()
17
    {
18
        $this->initPlainInput();
19
20
        $this->prepend('<i class="fa fa-pencil fa-fw"></i>')
21
            ->defaultAttribute('type', 'text')
22
            ->defaultAttribute('id', $this->id)
23
            ->defaultAttribute('name', $this->elementName ?: $this->formatName($this->column))
24
            ->defaultAttribute('value', old($this->column, $this->value()))
25
            ->defaultAttribute('class', 'form-control '.$this->getElementClassString())
26
            ->defaultAttribute('placeholder', $this->getPlaceholder());
27
28
        $this->addVariables([
29
            'prepend' => $this->prepend,
30
            'append'  => $this->append,
31
        ]);
32
33
        return parent::render();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::render(); of type string|Illuminate\View\V...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 33 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
34
    }
35
36
    public function datalist( $entries = [] ) {
37
        $this->defaultAttribute('list', "list-{$this->id}");
38
        $datalist = "<datalist id=\"list-{$this->id}\">";
39
        foreach($entries as $k => $v) {
40
            $datalist .= "<option value=\"{$k}\">{$v}</option>";
41
        }
42
        $datalist .= "</datalist>";
43
        $this->append($datalist);
44
    }
45
}
46