Skip to content

Commit

Permalink
Fix input issue
Browse files Browse the repository at this point in the history
  • Loading branch information
muath-ye committed Aug 3, 2022
1 parent 3bcb385 commit fabafff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions resources/views/components/forms/string-input.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
<input name="{{ $name }}" {{ !isset($type) ?'': "type=$type" }} {{ !isset($class) ?'': "class=$class" }} {{ !isset($id) ?'': "id=$id" }} {{ !isset($placeholder) ?'': "$placeholder" }}
placeholder="" onchange="stringInputUpdated(this)" />
<input name="{{ $name }}" {{ !isset($type) ?'': "type=$type" }} {{ !isset($class) ?'': "class=$class" }} {{ !isset($id) ?'': "id=$id" }} {{ !isset($placeholder) ?'': "placeholder=$placeholder" }}
onchange="stringInputUpdated(this)" />

<script>
function stringInputUpdated(element) {
Expand Down
12 changes: 8 additions & 4 deletions src/Components/Forms/StringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@

namespace YemeniOpenSource\BladeRealtimeInput\Components\Forms;

use Closure;
use Illuminate\View\Component;

class StringInput extends Component
{
public $name;

public $rules;

public $type = 'text';

public $id = '';

public $class = '';

public $placeholder = '';

/**
* Create the component instance.
*
Expand All @@ -24,10 +28,10 @@ class StringInput extends Component
* @param string $id
* @param string $class
* @param string $placeholder
* @param boolean $is_repeated
* @param bool $is_repeated
* @return void
*/
public function __construct($name, $rules, $type='text', $id = '', $class = '', $placeholder = '')
public function __construct($name, $rules, $type = 'text', $id = '', $class = '', $placeholder = '')
{
$this->name = $name;
$this->rules = $rules;
Expand Down
3 changes: 2 additions & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
Route::post('validate', function (Request $request) {
$validator = Validator::make($request->all(), $request->rules);
if ($validator->fails()) {
return response()->json($validator->errors() );
return response()->json($validator->errors());
}

return response()->json(['inputIndex' => '']);
})->name('realtime-input.validator');

0 comments on commit fabafff

Please sign in to comment.