vojtech-dobes/nette-forms-inputlist 问题修复 & 功能扩展

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

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

vojtech-dobes/nette-forms-inputlist

最新稳定版本:1.0.4

Composer 安装命令:

composer require vojtech-dobes/nette-forms-inputlist

包简介

Alternative RadioList & CheckboxList for Nette Framework

README 文档

README

Alternative RadioList & CheckboxList for Nette Framework

License

New BSD

Dependencies

Nette 2.0.0

Installation

  1. Get the source code from Github or via Composer (vojtech-dobes/nette-forms-inputlist).
  2. Register VojtechDobes\NetteForms\InputListExtension as extension for $configurator.
$configurator->onCompile[] = function ($configurator, $compiler) {
	$compiler->addExtension('inputlist', new VojtechDobes\NetteForms\InputListExtension);
};

Usage

RadioList

$form->addMultiRadio('sex', 'Sex:', array(
	'male' => 'Male',
	'female' => 'Female',
));

Method's name was chosen to not interfere with native addRadiolist.

CheckboxList

$checkboxlist = $form->addMultiCheckbox('topics', 'I like:', array(
	'l' => 'lifestyle',
	'm' => 'military',
	'c' => 'computers',
	'f' => 'flowers',
));
Defaults
$checkboxlist->setDefaultValue(array('l', 'm')); // lifestyle, military
Returned values
$checkboxlist->getValue() === array(0 => 'l', 1 => 'm')

Rendering

Automatic

Both RadioList and CheckboxList provide standard mechanism like getControlPrototype etc. You can also force omitting of last separator:

$radiolist->omitLastSeparator();

Manual

There is special new macro for Latte templates: {inputlist}. It behaves exactly like {foreach}, but it's specifically design to work with *List form elements.

{form formName}
	{inputlist sex as $key => $label}
		{input} {label /} {sep}<br>{/sep}
	{/inputlist}
{/form}

Macros {input} and {label} behave the same way as always, but when used without element identificator, they will render proper elements for iteration specific item. If you use it with identificator, it will render appropriate element from form.

{form formName}
	{inputlist sex as $key => $label}
		{input} {label /}<br>
		{input send} {* standard button, no problem *}
	{/inputlist}
{/form}

You can add HTML attributes to them as usually.

{form formName}
	{inputlist sex as $key => $label}
		{input class => 'input-radio'} {label}{$label}{/label}<br>
	{/inputlist}
{/form}

Attribute version of {inputlist} is also possible:

{form formName}
	<ul n:inner-inputlist="sex as $key => $label">
		<li>{input} {label /}</li>
	</ul>
{/form}

Validation

Here supported rules are listed:

CheckboxList

Form::FILLED At least one box must be checked.
Form::LENGTH Exact amount of boxes that must be checked.
Form::MIN_LENGTH Minimum amount of boxes that must be checked.
Form::MAX_LENGTH Maximum amount of boxes that must be checked.
Form::RANGE Minimum and maximum amount of boxes that must be checked.
Form::REGEXP Checks if selected checkbox values match regular expression.

RadioList

Form::FILLED One button must be selected.
Form::REGEXP Checks if selected radio value matches regular expression.

All rules are also supported on client-side.

统计信息

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

GitHub 信息

  • Stars: 24
  • Watchers: 7
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: New
  • 更新时间: 2012-12-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固