I a laravel project using React js for the font-end , i would like to pass some data rendered by a React component to my controller. In a blade template i have a form , and within that form , i'm displaying a "select" element using React js. How to pass the value in the select element via the Request(Request $request) variable to the controller? Here is my form in the blade template:
<form method="POST" action="">
@csrf
<div id="example" data={{ $currencies }}></div>
<input type="submit" value="Create" class="btn btn-primary">
</form>
And there is the component:
class Example extends Component {
render() {
return(
<div>
<select>
<option></option>
<option>Currency</option>
<option>Reputation</option>
</select>
</div>
);
}
}
export default Example;
if (document.getElementById('example')) {
var data = document.getElementById('example').getAttribute('data');
ReactDOM.render(<Example data={data}/>, document.getElementById('example'));
}