jnjxp/form
Composer 安装命令:
composer require jnjxp/form
包简介
Describe collections of HTML form inputs
README 文档
README
Describe collections of HTML form inputs
Installation
composer require jnjxp/form
Usage
$form = (new Jnjxp\Form\FieldFactory)->newFieldCollection(); $form->add('username') ->type('text') ->label('Username') ->attribs(['required' => true]) ->help('Enter username or email address'); $form->add('password') ->type('password') ->label('Password') ->attribs(['required' => true]); $data = $filter->apply($input); $form->fill($data); $form->errors($filter->getFailures()->getMessages()); foreach ($form as $field) { $group = ['form-group']; $label = ['class' => 'control-label']; if ($field->id) { $group[] = 'form-group_' . $field->id; $label['for'] = $field->id; } if ($field->errors) { $group[] = 'has-errors'; } echo $helper->tag('div', ['class' => $group]); if ($field->label) { echo PHP_EOL; echo $helper->label($field->label, $label); } echo PHP_EOL; echo $helper->input($field->spec); if ($field->help) { echo PHP_EOL; echo $helper->tag('p', ['class' => 'help-block']); echo $field->help; echo $helper->tag('/p'); } if ($field->errors) { $errors = $helper->ul(['class' => 'errors']); $errors->items($field->errors); echo PHP_EOL; echo $errors; echo PHP_EOL; } echo $helper->tag('/div') . PHP_EOL; echo PHP_EOL; }
统计信息
- 总下载量: 265
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-29