modul-is/form 问题修复 & 功能扩展

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

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

modul-is/form

Composer 安装命令:

composer require modul-is/form

包简介

Simplified nette forms

README 文档

README

This library allows you to spend less time writing templates for Nette forms - it contains renderers for form, containers as well as all inputs

Getting started

Easiest way to create form is to create component which extends FormComponent class

class MyForm extends \ModulIS\Form\FormComponent
{
	public function createComponentForm(): Form
	{
		$form = $this->getForm();
		
		...
		
		return $form;
	}
}

Then you just add inputs to form, create MyForm component and all done!

Inputs

Form supports all of the default Nette inputs and adds new ones

  • addLink() - Button with link (eg. reset, go back buttons)
  • addWhisperer() - select box with whisperer which filters options
  • addMultiWhisperer() - same as whisperer, more options can be selected
  • addDuplicator() - container which can be duplicated many times
  • addDependentSelect() - select box that can change options via ajax based on change of another input(s)
  • addDependentMultiSelect() - same as DependentSelect, but more options can be selected
  • addDate() - date input, can limit min and max date

Custom settings

Form

  • setTitle() - add card-header div with title
  • setColor() - set color of form
  • setAjax() - form is submitted via ajax
  • addBox() - all inputs added after this call will render in new card
  • setFloatingLabel() - inputs will be rendered with floating labels
  • setRenderInline() - label and input are rendered each in separate row
  • setButtonClass() - default CSS class for all form buttons (e.g. rounded rounded-4); can be overridden by setClass() on individual buttons
  • setRenderManually() - set manual render, template with same name as form is used (eg. file MyForm.php -> myForm.latte)

Groups

Form is rendered in BS5 card - each card represents one group

Inputs are rendered in card-body div

Submitters, links and buttons in card-footer

Container

Container works as standard Nette Container and has these new features

  • setId() - add html id to outer div of container
  • showCard() - show container as BS5 card
  • setTitle() - show title of container (only works when container is rendered as card)
  • setColor() - set color of container (only works when container is rendered as card)

Currency input

addCurrency() - numeric input that visually formats values with thousands separators (e.g. 1 000 000) but returns a plain integer on submit. Currency label is appended to the input.

Default currency can be set globally for the whole project (e.g. in bootstrap or DI extension):

\ModulIS\Form\Control\CurrencyInput::setDefaultCurrency('CZK');

Per-input currency can be set via:

$form->addCurrency('price', 'Price', 'EUR');
// or
$form->addCurrency('price', 'Price')->setCurrency('EUR');

Inputs

Some inputs provide new features

  • setIcon() - add icon to input or button (Buttons, Links, Text inputs)
  • setColor() - add color to input or button (Buttons, Links, Checkbox, Lists)
  • setTemplate() - add custom latte template instead of basic render (All inputs)
  • setPrepend() - adds prepend part to input group (Text inputs, Select boxes)
  • setAppend() - adds append part to input group (Text inputs, Select boxes)
  • setRenderInline() - render label and input each in separate row, overwrites renderInline setting from Form (All non-button inputs)
  • setFloatingLabel() - input will be rendered with floating labels (Text inputs, Select box)
  • setAutorenderSkip() - skips rendering of input, eg. if input is rendered as part of another input with custom template (All inputs)
  • setTooltip() - add icon with tooltip to input (Text inputs, Checkbox, Lists, Select boxes)
  • setQuickCopy() - add button to copy input value to clipboard (Text inputs, TextArea)
  • setWrapClass() - set class to outer div around label and input - overwrites basic col- class (Text inputs, Checkbox, Lists, Select boxes)
  • setLabelWrapClass() - set class to wrap div around label - overwrites basic col- class (Text inputs, Checkbox, Lists, Select boxes)
  • setInputWrapClass() - set class to wrap div around input - overwrites basic col- class (Text inputs, Checkbox, Lists, Select boxes)

Duplicator example

$duplicator = $form->addDuplicator('duplicator', function(\ModulIS\Form\DuplicatorContainer $container)
{
	$container->addText('text', 'Text input');

	$container->addSubmit('del', 'Smazat');
}, 1);

$duplicator->addSubmit('add', 'Přidat');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固