seanmorris/form 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

seanmorris/form

Composer 安装命令:

composer require seanmorris/form

包简介

Simple, Object oriented forms for PHP.

README 文档

README

Rapid, themable forms for PHP.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

The Form library allows you to rapidly develop, theme, and validate forms, so you can get back to programming.

Creating a Form

Creating a form is simple. Elements starting with a letter or number are fields. Elements starting with underscores are special keys. For example _method allows you to set the choose a GET or POST request for your form.

Elements starting with a letter or number are rendered directly into the <input> or <select> tag. Elements beginning with an underscore are passed to logic but not rendered.

For example, the _title attribute generates a <label tag for the form field.

$skeleton['_method'] = 'POST';

$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
];

$skeleton['submit'] = [
  '_title' => 'Submit'
  , 'type' => 'submit'
];

$form = new \SeanMorris\Form\Form($skeleton);

echo $form->render();

Validation

Validators are specified on the _validators key. Its an array keyed by validator class. The values are arrays of arguments to pass to the constructor.

$skeleton['testField'] = [
  'type' => 'text'
  , '_title' => 'Test Field'
  , '_validators' => [
    'SeanMorris\Form\Validator\Regex' => [
      '/.{8,}/' => '%s must be at least 8 characters'
    ]
  ]
];

Filtering and validating submitted values is simple:

$form->setValues($_POST);

if($form->validate())
{
  // Values will only contain keys for each of the fields.
  $values = $form->getValues();
}
else
{
  $errors = $form->erorrs();
}

More...

For the field type list, validator list, and usage guide read DOCS.

For the guide to extending the library to create new field types, read EXTENDING.

For legal information, check LICENSE and NOTICE.

README

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-02-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固