'How do I generate an id for form data input to save the data in an array?
Good day all I have a simple laravel project that takes some information about actors and saves it in a json file after the user fills in the form.My problem is that I save simple data like name, surname, nationality ,age I need a Id something like "edf33e5751b2ea2fd25ad118edbc647e" to save the data in a json file by using arrays.How do I take the user input data from the form add an ID to the data so I can save it to a json file and later use the data by ID? This is my form where I get my data and send it to my controller to be saved.
<form method="POST" action="{{route('actor.store')}}">
@csrf
<div class="form-row">
<div class="form-group col-md-6">
<label for="input">Actor Name</label>
<input type="text" class="form-control" placeholder="Actor Name" name ="name" required="required" minlength="3" maxlegnth="30">
</div>
<div class="form-group col-md-6">
<label for="input">Actor Surname</label>
<input type="text" required="required" minlength="3" maxlegnth="30" class="form-control" id="actorSurname" placeholder="Actor Surname" name ="surName">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="input">Actor Nationallity</label>
<select id="nationallity" class="form-control" name ="nationallity" required="required" minlength="3" maxlegnth="30" >
<option selected>--Select Actor Nationallity.</option>
<option>South African</option>
</select>
</div>
<div class="form-group col-md-6">
<label for="input">Actor Age</label>
<input type="number" required="required" class="form-control" id="actorAge" placeholder="Actor Age" name ="age">
</div>
</div>
<a class="btn btn-primary" href="/actor/index" role="button">Back to List</a>
<button type="submit" class="btn btn-primary">Create</button>
</form>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
