I just found out how to do it! Here is the answer:
In Voyager, every input you can use in the forms is already defined (also you can define custom inputs). In my case, I needed the coordinates form input, which shows a google map and lets you put a marker, saving latitude and longitude.
This is how you include it in a custom form:
@php
$dataTypeRows = $dataType->{(isset($dataTypeContent->id) ? 'editRows' : 'addRows' )};
$row = $dataTypeRows->where('field', 'location')->first();
$options = $row->details;
@endphp
@include('voyager::formfields.coordinates')
So what this all mean:
The first line ($dataTypeRows = $dataType->{(isset($dataTypeContent->id) ? 'editRows' : 'addRows' )};
), basically tells if u are editing or adding (i.e., a new user).
In the second line ($row = $dataTypeRows->where('field', 'location')->first();
), you get all the row data for "location" of the specific model. "location" is the name I've used in my case, there you must replace with the name you have set in your BREAD.
In the third line ($options = $row->details;
), you get the details (custom json code you can put in each field in the BREAD).
Doing this, you only just set the data needed in the form field "coordinates", so you have to include the form field (google map) now. You do this in this final line: @include('voyager::formfields.coordinates')
.
Finally, with all the html, it could be like this:
<div class="row">
<div class="col-md-12">
<div class="panel panel-bordered">
<div class="panel-body">
<label for="location"> Ubicación </label>
@php
$dataTypeRows = $dataType->{(isset($dataTypeContent->id) ? 'editRows' : 'addRows' )};
$row = $dataTypeRows->where('field', 'location')->first();
$options = $row->details;
@endphp
@include('voyager::formfields.coordinates')
</div>
</div>
</div>
</div>
