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

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

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

laasti/form

最新稳定版本:v0.2.2

Composer 安装命令:

composer require laasti/form

包简介

README 文档

README

Installation

composer require laasti/form

Usage

Forms have groups containing multiple fields.

$form = new Laasti\Form\Form($data, $errors, $rules);
$form->setMethod('post'); //Defaults to post
$form->setAction('url');
$form->setAttributes([/*html attributes*/]);
$form->addField('text', 'field', 'Label', [/*choices*/], 'group', [/*input attributes*/], [/*row attributes*/]);
$form->removeField('field');
$form->removeGroup('group');
$form->setGroup('field', 'group');
$form->setLabel('field', 'Label');
$form->setType('field', 'type');
$form->setAttributes('field', [/*attributes*/]);
$form->setContainerAttributes('field', [/*attributes*/]);
$form->setData([]);
$form->setErrors([]);
$form->setRules([]);
$form->setGroupsLayout([
    'top',
    'main' => ['column1', 'column2'],
    'secondary' => ['side', 'wide'],
    'multi-level' => [
        'subsection' => ['sub-column1', 'sub-column2'],
        'subsection2'
    ]
]);
$form->defineGroup('group', 'Title', [/*attributes*/]);

Then in your view:

$form->getAction(); //Get form action attribute
$form->getMethod(); //Get form method
$form->getFormAttributes(); //Get form attributes
$form->getAllFields(); //All fields without groups
$form->getFields(); //Just fields without groups
$group = array_shift($form->getGroups()); //Array of first level groups
$group->getLabel();
$group->getAttributes();
$group->getGroups(); //Array of subgroups
$field = array_shift($group->getFields()); //Array of fields in group
$field->getLabel();
$field->getName();
$field->getGroup();
$field->getChoices();
$field->getAttributes();
$field->getContainerAttributes();

//OR you can use magic properties instead of lengthy getters in views
$field->choices;
$field->containerAttributes;

//There are some magic properties as well
$field->isRequired;//Checks if required exists in $field->attributes
$field->is{Name};//If you want to identify a field by its name
$field->is{Type};//If you want to check a field's type

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

See CHANGELOG.md for more information.

Credits

Author: Sonia Marquette (@nebulousGirl)

License

Released under the MIT License. See LICENSE.txt file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固