定制 binaryspanner/quickforms 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

binaryspanner/quickforms

Composer 安装命令:

composer require binaryspanner/quickforms

包简介

A Symfony bundle to allow the creation of forms from YML files.

README 文档

README

Build Status Test Coverage Code Climate Issue Count

Quick Forms

A Symfony bundle to allow the creation of forms from YML files.

Installation

The bundle can be installed using Composer:

composer require binaryspanner/quickforms

Use

First the bundle needs registered in the Symfony app's kernel:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        // ...
        new BinarySpanner\QuickForms\QuickFormsBundle(),
    ];
    
    // ...
}

When using the default settings the bundle will search for form files in Resources/forms in the kernel's root directory (normally "path-to-Symfony-project"/app/).

To load form files the filenames have to be added to the bundle's settings in config.yml:

# app/config/config.yml
# ...
quick_forms:
    file_names: [ 'file1.yml', 'file2.yml', ...]

An example form file can be found in the bundle's Resources/forms directory. This form file will be loaded by default when the bundle's file_names property is unset in config.yml.

The directories the bundle searches in can be changed by modifying the root_paths and/or directory_paths bundle settings in config.yml:

# app/config/config.yml
# ...
quick_forms:
    root_paths: [ '%kernel.root_dir%', '%kernel.root_dir%/../src' ]
    directory_paths: [ 'custom/forms' ]
    file_names: [ 'file1.yml', 'file2.yml', ...]

Note that absolute paths can be used in the directory_paths setting.

Once the form layout files have been setup a view template needs to be created - if you're using Twig you can create Symfony forms as normal:

{# app/Resources/views/quickform/form.html.twig #}
{% extends 'base.html.twig' %}
 
{% block body %}
    Form One:
    {% form_theme forms.example_form_one.view forms.example_form_one.theme %}
    {{ form_start(forms.example_form_one.view) }}
    {{ form_widget(forms.example_form_one.view) }}
    {{ form_end(forms.example_form_one.view) }}
 
    Form Two:
    {% form_theme forms.example_form_two.view forms.example_form_two.theme %}
    {{ form_start(forms.example_form_two.view) }}
    {{ form_widget(forms.example_form_two.view) }}
    {{ form_end(forms.example_form_two.view) }}
{% endblock %}

Finally the views need to be loaded in the controller:

// src/AppBundle/Controller/DefaultController.php
// ...
/**
 * @Route("/quickforms", name="quickforms")
 */
public function quickForms()
{
    $quickForms = $this->get('quick_forms');

    $forms = $quickForms->loadForms();

    return $this->render('quickform/form.html.twig', array(
        'forms' => $forms
    ));
}

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固