how add model to form-builder?

Asked by At

I have model:

public function up()
        Schema::create('tourist_objects', function (Blueprint $table) {
            $table->string('name', 255);
            $table->engine = "InnoDB";

I want use this component and create form. How can I create this form:

<form method="POST" action="">
    <input name="_token" type="hidden" value="xxxxxxxxxxxxxx">
    <div class="form-group">
        <label for="name" max-length="255" class="control-label">Name</label>
        <input type="text" class="form-control" id="name" value="Name from model">
    <div class="form-group">
        <label for="lyrics" class="control-label">Description</label>
        <textarea name="lyrics" class="form-control">description value from data base</textarea>
    <input type="submit" value="Save form">


Could I ask for an example with my data?

1 Answers


You could use the command line to create a a form class:

php artisan make:form Forms/SongForm --fields="name:text, description:textarea, city_id:number, user_id:number"

If you want the city_id and user_id fields to be populated with data from the respecting models you could use the choice fields: