PHP code example of erdemozveren / laravelmacros

1. Go to this page and download the library: Download erdemozveren/laravelmacros 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/ */

    

erdemozveren / laravelmacros example snippets


public function formFields() {
    return [
        "*"=>[ // wildcard will be applied to all elements 
            "options"=>
            ["style"=>"color:red!important"]
        ],
        "parent_id"=>[ // "parent_id" is the name attribute
            "type"=>"select", // input type (e.g. "select" will look for "cSelect")
            "label"=>"Parent", // label text
            "data"=>User::pluck('full_name','id'), // [ONLY FOR select] you can write any data source that laravel collective accepts
            "options"=>[ // optional
                "

{!!Form::model($model,['url'=>"/post"])!!}
{!!$model->generateForm()!!}
{!!Form::cSubmit()!!}
{!!Form::close()!!}

{!!Form::open(['url'=>"/post"])!!}
{!!$model->generateForm()!!}
{!!Form::cSubmit()!!}
{!!Form::close()!!}

{!!$model->generateForm(["_exclude"=>["full_name","another_filed_name"]])!!}

// variable names stand for paramaters with default values

Form::cText($name,$label,$placeholder=null,$options=[]);

Form::cColor($name,$label,$options=[]);

Form::cTextarea($name,$label,$placeholder=null,$options=[]);

Form::cNumber($name,$label,$options=[]);

Form::cEmail($name,$label,$placeholder=null,$options=[]);

Form::cPassword($name,$label,$placeholder="*******",$options=[]);

Form::cFile($name,$label,$options=[]);

Form::cCheckbox($name,$label,$value=1,$checked=null);

Form::cRadio($name,$label,$value,$checked=null);

Form::cSubmit($label="Submit",$class="");

Form::cSelect($name,$label,$data,$options=[]);

 bash
$ php artisan laravelmacros:formfields {tablename}