Эх сурвалжийг харах

调整验证码表单功能

jqh 6 жил өмнө
parent
commit
57215ea626

+ 3 - 2
resources/views/form/captcha.blade.php

@@ -10,8 +10,9 @@
 
             <input {!! $attributes !!} />
 
-            <span class="input-group-addon clearfix" style="padding: 1px;"><img id="{{$column}}-captcha" src="{{ captcha_src() }}" style="height:30px;cursor: pointer;"  title="Click to refresh"/></span>
-
+            <span class="input-group-addon clearfix" style="padding: 1px;">
+                <img class="field-refresh-captcha" data-url="{{ $captchaSrc }}" src="{{ $captchaSrc }}" style="height:30px;cursor: pointer;"  title="Click to refresh"/>
+            </span>
         </div>
 
         @include('admin::form.help-block')

+ 4 - 2
src/Form/Field/Captcha.php

@@ -32,11 +32,13 @@ class Captcha extends Text
     public function render()
     {
         $this->script = <<<JS
-$('#{$this->column}-captcha').click(function () {
-    $(this).attr('src', $(this).attr('src')+'?'+Math.random());
+$('.field-refresh-captcha').off('click').click(function () {
+    $(this).attr('src', $(this).attr('data-url')+'?'+Math.random());
 });
 JS;
 
+        $this->addVariables(['captchaSrc' => captcha_src()]);
+
         return parent::render();
     }
 }