Laravael PHP,需要JavaScript帮助

时间:2019-01-29 13:17:42

标签: javascript php laravel

首先,我是C,C ++,C#,Android和Swift的开发人员,但我绝对没有JavaScript,PHP或Web开发方面的经验。

我为后端服务器购买了一些源代码。我可以在这里输入产品并进行存储。现在,我有了一切工作(即使在Web开发中只有0 Knowledgedlege),但是有一个文本输入字段可以检查整数值。我想插入十进制值,例如价格信息,例如19.99。然后,它抱怨必须是19或20。我找不到更改该位置的位置,也找不到哪个类/函数负责检查输入的值。有一种叫做Blade的东西。在我看来,它是用HTML和javaScript编写的。我找不到输入的值去检查的任何类或到文件的路由。我什至不知道哪个类/文件负责将值写入数据库。我的意思是,wtf?找出负责处理输入值的文件并不是那么复杂。它让我疯狂。 enter image description here

那是只接受整数值的输入。

这是刀片服务器代码:

{{-- resources/views/admin/dashboard.blade.php --}}
@extends('adminlte::page')

@section('title', 'Products')

@include('parts.header')

@section('content_header')
    <div class="col-md-12">
        <h2>Add new product</h2>
    </div>

@stop

@section('content')
    <div class="row">
        <div class="col-sm-12">
            <form method="post" action="{{ route('product.add') }}" enctype="multipart/form-data">
                {{ csrf_field() }}

                @if(!$errors->isEmpty())
                    <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-ban"></i> Alert!</h4>
                        @foreach ($errors->all() as $error)
                            <div>{{ $error }}</div>
                        @endforeach
                     </div>
                @endif

            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">Details</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form role="form">
                        <div class="box-body">
                            <div class="row">
                                <div class="col-sm-4 form-group ">
                                    <label for="name">Name</label>
                                    <input type="text" name="name" class="form-control" id="name" placeholder="Enter name" required>
                                </div>
                                <div class="col-sm-4 form-group ">
                                    <label for="name">Description</label>
                                    <input type="text" name="description" class="form-control" id="name" placeholder="Enter description" required>
                                </div>
                                <div class="col-sm-3 form-group ">
                                    <label for="category">Select category</label>
                                    <select name="category_id" class="form-control" required>
                                        <option value="" disabled selected>Select your option</option>
                                        @foreach($categories as $category)
                                            <option value="{{ $category->id }}">{{ $category->name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-4 form-group">
                                    <label for="price">Price</label>
                                    <input type="number" name="price" class="form-control" id="price" placeholder="Enter price" required>
                                </div>
                                <div class="col-sm-4 form-group">
                                    <label for="amount">Amount</label>
                                    <input type="number" name="amount" class="form-control" id="amount" placeholder="Enter amount" required>
                                </div>
                                <div class="col-sm-3 form-group">
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <img id="myImg" alt="" style="width: 100%;">
                                        </div>
                                        <div class="col-sm-6">
                                            <label for="image">Image</label>
                                            <input class="fullwidth input rqd" type="file" name="image" id="image" accept="image/*" onclick="fileClicked(event)" onchange="fileChanged(event)" required>
                                            <div id="log"></div>
                                        </div>
                                    </div>
                                </div>

                            </div>


                            <div class="row">
                                <div class="col-sm-6">
                                    <h4>Variations</h4>
                                    <div class="box-body table-responsive no-padding">
                                        <table id="variationTable" class="table table-bordered table-hover dataTable" role="grid">
                                            <thead>
                                            <tr role="row">
                                                <th rowspan="1" colspan="1">#</th>
                                                <th rowspan="1" colspan="1">Owner</th>
                                                <th rowspan="1" colspan="1">Remove</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            <tr role="row" class="odd">
                                                <td>1</td>
                                                <td>
                                                    <input type="text" name="owner_id[]" placeholder="Enter owner" required>
                                                </td>
                                                <td>
                                                    <i class="fa fa-fw fa-remove"></i>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <button type="button" class="btn btn-default btn-sm addrow pull-right" style="height: 34px;">
                                        <span class="glyphicon glyphicon-plus-sign"></span> Add
                                    </button>
                                    <div class="clearfix"></div>

                                    <div>
                                        <button type="submit" class="btn btn-primary">Submit</button>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <h4>Siblings</h4>


                                    <div class="form-group">
                                        <select name="siblings[]" class="form-control select2" multiple>
                                            @foreach($products as $product)
                                                <option value="{{ $product->id }}">{{ $product->name }} </option>
                                            @endforeach
                                        </select>
                                    </div>


                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                    </form>
                </div>
            </div>
        </form>
    </div>
</div>
@stop



@section('js')
    @include('parts.footer');
@stop

有人可以告诉我在哪里可以找到处理输入的代码吗?在哪里找到检查整数的函数?我确实搜索了每个文件,但是对于这个Web东西,我有点愚蠢。

提到了类似一个类的东西:col-sm-4 form-group但我找不到它?!?

谢谢。

4 个答案:

答案 0 :(得分:1)

使用step属性输入数字

Float
<input type="number" step="0.01">
Int
<input type="number">

答案 1 :(得分:1)

转到app / Http目录;那么您必须检查用于处理该视图的控制器。在控制器文件中查找验证器方法。就像这样:

<php?
   protected function validator(array $data)
    {
        return Validator::make($data, [
            'price' => 'required|string|min:19|max:20'
        ]);
    }

您可以根据需要进行更改。

答案 2 :(得分:0)

step="0.01"(例如0.01)属性添加到您的价格输入中。

答案 3 :(得分:0)

如果在客户端进行了检查,则可以检查resources/views/parts/footer并找出模板中包含哪些javascript文件,然后检查该javascript文件是否进行验证。
如果是服务器端,则最常见的验证位置是app/Http/Requests。但是在提出请求之前,您应该检查负责响应该请求的Controller和操作,并检查哪个Request类是该操作的输入参数,然后进入app/Http/Requests并找到该类并编辑验证规则

相关问题