Nvd\Crud\Db::getFormInputMarkup PHP Method

getFormInputMarkup() public static method

public static getFormInputMarkup ( $field, $modelName = '' )
    public static function getFormInputMarkup($field, $modelName = '')
    {
        // skip certain fields
        if (in_array($field->name, static::skippedFields())) {
            return "";
        }
        // string that binds the model
        $modelStr = $modelName ? '->model($' . $modelName . ')' : '';
        // selects
        if ($field->type == 'enum') {
            return "{!! \\Nvd\\Crud\\Form::select( '{$field->name}', [ '" . join("', '", $field->enumValues) . "' ] ){$modelStr}->show() !!}";
        }
        if ($field->type == 'text') {
            return "{!! \\Nvd\\Crud\\Form::textarea( '{$field->name}' ){$modelStr}->show() !!}";
        }
        // input type:
        $type = 'text';
        if ($field->type == 'date') {
            $type = $field->type;
        }
        return "{!! \\Nvd\\Crud\\Form::input('{$field->name}','{$type}'){$modelStr}->show() !!}";
    }

Usage Example

示例#1
0
}}</h2>

    <form action="/<?php 
echo $gen->route();
?>
/{{$<?php 
echo $gen->modelVariableName();
?>
->id}}" method="post">

        {{ csrf_field() }}

        {{ method_field("PUT") }}
<?php 
foreach ($fields as $field) {
    if ($str = \Nvd\Crud\Db::getFormInputMarkup($field, $gen->modelVariableName())) {
        ?>

        <?php 
        echo $str;
        ?>

<?php 
    }
}
?>

        <button type="submit" class="btn btn-default">Submit</button>

    </form>
All Usage Examples Of Nvd\Crud\Db::getFormInputMarkup