Test Failed
Branch master (1557a3)
by Adam
08:20
created

CloneForm::buildForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 0
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
1
<?php
2
3
namespace Coyote\Http\Forms\Wiki;
4
5
use Coyote\Repositories\Contracts\WikiRepositoryInterface as WikiRepository;
6
use Coyote\Services\FormBuilder\Form;
7
use Coyote\Services\FormBuilder\ValidatesWhenSubmitted;
8
9
class CloneForm extends Form implements ValidatesWhenSubmitted
10
{
11
    use TreeListTrait;
12
13
    protected $theme = self::THEME_INLINE;
14
15
    /**
16
     * @var WikiRepository
17
     */
18
    protected $wiki;
19
20
    /**
21
     * @param WikiRepository $wiki
22
     */
23
    public function __construct(WikiRepository $wiki)
24
    {
25
        parent::__construct();
26
27
        $this->wiki = $wiki;
28
    }
29
30
    public function buildForm()
31
    {
32
        $parentId = $this->request->input('parent_id');
33
34
        $this
35
            ->add('title', 'text', [
36
                'rules' => sprintf('required|wiki_route:%d|wiki_unique:0,%d', $parentId, $parentId),
0 ignored issues
show
Bug introduced by
$parentId of type array is incompatible with the type string expected by parameter $args of sprintf(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
                'rules' => sprintf('required|wiki_route:%d|wiki_unique:0,%d', /** @scrutinizer ignore-type */ $parentId, $parentId),
Loading history...
37
                'label' => 'Tytuł',
38
                'attr' => [
39
                    'readonly' => 'readonly'
40
                ]
41
            ])
42
            ->add('parent_id', 'select', [
43
                'label' => 'Nowa strona macierzysta',
44
                'rules' => 'sometimes|int|exists:wiki_paths,path_id',
45
                'choices' => $this->getTreeList(),
46
                'empty_value' => '--',
47
                'value' => ''
48
            ])
49
            ->add('submit', 'submit', [
50
                'label' => 'Kopiuj',
51
                'attr' => [
52
                    'data-submit-state' => 'Kopiowanie...'
53
                ]
54
            ]);
55
    }
56
}
57