spotonlive/sl-laravel-zf2-form
Composer 安装命令:
composer require spotonlive/sl-laravel-zf2-form
包简介
ZF2 Forms in Laravel 5.1
关键字:
README 文档
README
ZF2 form integration for Laravel 5.1
Installation
Composer
Run $ composer require spotonlive/sl-laravel-zf2-form
Helper
Add the helper/facade to your aliases.
config/app.php
return [ 'aliases' => [ 'Form' => SpotOnLive\LaravelZf2Form\Facades\Helpers\FormHelperFacade::class, ] ];
Example
Form
<?php namespace App\Forms\Customer; use Zend\Form\Form; use App\Entities\Country; use App\Entities\Customer; use Zend\Form\Element\Text; use Zend\InputFilter\FileInput; use Zend\InputFilter\InputFilter; use Zend\InputFilter\InputFilterInterface; use DoctrineModule\Form\Element\ObjectSelect; use Doctrine\Common\Persistence\ObjectManager; use Zend\InputFilter\InputFilterAwareInterface; use DoctrineModule\Stdlib\Hydrator\DoctrineObject as DoctrineHydrator; class CreateForm extends Form { /** @var ObjectManager */ protected $objectManager; protected $inputFilter; public function __construct($name = null, ObjectManager $objectManager) { $this->objectManager = $objectManager; $this->setHydrator(new DoctrineHydrator($objectManager, Customer::class)); $this->setObject(new Customer()); parent::__construct('create-customer'); $this->add([ 'name' => 'name', 'type' => Text::class, 'options' => [ 'label' => 'Name', ], 'attributes' => [ 'class' => 'form-control', 'required' => true, ], ]); $this->add([ 'name' => 'country', 'type' => ObjectSelect::class, 'options' => [ 'type' => 'select', 'label' => 'Country', 'object_manager' => $objectManager, 'target_class' => Country::class, 'label_generator' => function(Country $country) { return sprintf( '%s (%s)', $country->getName(), $country->getCode() ); }, 'empty_option' => '-- Select country --', ], 'attributes' => [ 'class' => 'form-control', 'required' => true, ], ]); } public function getInputFilter() { if (!$this->inputFilter) { $inputFilter = new InputFilter(); $inputFilter->add([ 'name' => 'name', 'required' => true, 'filters' => [ ['name' => 'StripTags'], ['name' => 'StringTrim'], ], 'validators' => [ [ 'name' => 'StringLength', 'options' => [ 'encoding' => 'UTF-8', 'min' => 1, 'max' => 255, ], ], ], ]); $inputFilter->add([ 'name' => 'country', 'required' => true, ]); $this->inputFilter = $inputFilter; } return $this->inputFilter; } }
View
@extends('layout') @section('content') <h1>{{_('Form')}}</h1> {!! Form::openTag($form) !!} {!! csrf_field() !!} {!! Form::row($form->get('name')) !!} {!! Form::row($form->get('country')) !!} {!! Form::button($form->get('submit')) !!} {!! Form::closeTag() !!} @endsection
Helper methods
- openTag
- closeTag
- button
- captcha
- checkbox
- collection
- color
- date
- dateSelect
- dateTime
- dateTimeLocal
- dateTimeSelect
- element
- elementErrors
- file
- hidden
- image
- input
- label
- month
- monthSelect
- multiCheckbox
- number
- password
- radio
- range
- reset
- row
- search
- select
- submit
- tel
- text
- textarea
- time
- url
- week
Documentation
Documentation for Zend Framework 2 forms: http://framework.zend.com/manual/current/en/modules/zend.form.elements.html
spotonlive/sl-laravel-zf2-form 适用场景与选型建议
spotonlive/sl-laravel-zf2-form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.68k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「zf2」 「Zend Framework」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spotonlive/sl-laravel-zf2-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spotonlive/sl-laravel-zf2-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spotonlive/sl-laravel-zf2-form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Polyfill for mb_ereg(), mb_eregi(), mb_ereg_match(), and mb_ereg_replace*() functions; primary use case is for mbstring on Windows 7.4+
Zend Framework module to leverage the symfony dependency injection container
RCM User HTML views/pages
统计信息
- 总下载量: 1.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-21