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; |
||
6 | |||
7 | class Captcha extends Text |
||
8 | { |
||
9 | protected $rules = 'required|captcha'; |
||
10 | |||
11 | protected $view = 'admin::form.captcha'; |
||
12 | |||
13 | public function __construct($column, $arguments = []) |
||
14 | { |
||
15 | if (!class_exists(\Mews\Captcha\Captcha::class)) { |
||
16 | throw new \Exception('To use captcha field, please install [mews/captcha] first.'); |
||
17 | } |
||
18 | |||
19 | $this->column = '__captcha__'; |
||
20 | $this->label = trans('admin.captcha'); |
||
21 | } |
||
22 | |||
23 | public function setForm(Form $form = null) |
||
24 | { |
||
25 | $this->form = $form; |
||
26 | |||
27 | $this->form->ignore($this->column); |
||
28 | |||
29 | return $this; |
||
30 | } |
||
31 | |||
32 | public function render() |
||
33 | { |
||
34 | $this->script = <<<EOT |
||
35 | |||
36 | $('#{$this->column}-captcha').click(function () { |
||
37 | $(this).attr('src', $(this).attr('src')+'?'+Math.random()); |
||
38 | }); |
||
39 | |||
40 | EOT; |
||
41 | |||
42 | return parent::render(); |
||
0 ignored issues
–
show
Bug
Compatibility
introduced
by
Loading history...
|
|||
43 | } |
||
44 | } |
||
45 |