-1

First, I am developer for C, C++, C#, Android and Swift but I have absolutly no experience in JavaScript or PHP or Web development.

I bought some source code for my backend server. It is kind of shop where I can enter products and store them. Now, I got everthying to work (even with 0 knowdlege in web development), but there is a text input field which checks for integer values. I want to insert decimal values like a price information, e.g. 19.99. It then complains that it has to be 19 or 20. I can not find the place where to change that or which class/function is responsible for checking that entered value. There is something called Blade. It is in HTML and javaScript as it seems to me. I can not find any class or a route to a file where the entered values go and get checked. I don't even know which class/file is responsible for writing the values to the database. I mean, wtf? It can not be that complicated to find out which file is responsible to handle the entered values. It drives me crazy. enter image description here

That is the input which only takes integer values.

This is the blade code:

{{-- 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

Can somebody tell me where to find the code which handles the input? Where to find the function which checks for integer? I really searched every file, but somehow I am too stupid for that web stuff.

There is something like a class mentioned: col-sm-4 form-group but I can not find it?!?

Thanks.

user1804084
  • 116
  • 1
  • 10

4 Answers4

1

Use step attribute for your number input

Float
<input type="number" step="0.01">
Int
<input type="number">
MakeLoveNotWar
  • 956
  • 9
  • 25
1

Go to app/Http directory; then you have to check for the controller that handles that very view. Look for validator method in the controller file. It is something like this:

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

You can change it as you want.

Emeka Augustine
  • 891
  • 1
  • 12
  • 17
0

Add step="0.01"(for example 0.01) property to your price input.

WKoppel
  • 504
  • 3
  • 15
0

If it's been checked on client side you can check resources/views/parts/footer and find out which javascript files are included in your template then check that javascript files for the validation.
If it's server side, most common place for validations is app/Http/Requests. but before going for requests you should check the Controller and action which is responsible for responding to that request and check which Request class is input paramter for that action then got to app/Http/Requests and find that class and edit validation rules

  • What I needed! But, how do I see in the Blade code which Controller is responsible? That is/was my problem all the time. There is no call hierarchy visible for me!? Who calls who? How does the entered data flow? That drove/drives me crazy. – user1804084 Jan 29 '19 at 13:58
  • first check `routes/web.php` or `routes/api.php` and find the route you need to check. in the simplest type you can find `Controller@action` in front of that route then go to 'app/Http/Controllers', you can find all controllers and inside each controller file you can find all actions of that controller. at body of the action you can find something like `return view('example.example')`. it is a little complicated and i suggest you to go for Laravel documentation – Mozafar Gholami Jan 29 '19 at 14:20
  • Perfect! That is what I needed! Thank you very much! – user1804084 Jan 29 '19 at 14:23