PHP code example of plokko / form-helper

1. Go to this page and download the library: Download plokko/form-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

plokko / form-helper example snippets


//...
use Plokko\FormHelper\FormHelper;

class TestController extends Controller
{
    //...
    public function example(Request $request){
        $form = new FormHelper();
        //Just an example model as data source
        $data = User::first();
        
        $form
            // Fill field values
            ->fill($data)
            // Specify form action and method
            ->action(route('users.edit',1),'patch')

            // Field definition:
            ->field('name')
                ->        ->label('Password')
                ->attr('min',3)

            ->field('filetest')
                ->type('file')
                ->label('File upload')
            
            //Redefine all the field labels using the specified translation array;
            // for example the trans id "users.fields.name" will be assigned as a label to "name"
            ->labelsFromTrans('users.fields')
            ;

        return view('your.blade.file',compact('form'));
    }
}