sheadawson/silverstripe-dependentdropdownfield 问题修复 & 功能扩展

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

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

sheadawson/silverstripe-dependentdropdownfield

Composer 安装命令:

composer require sheadawson/silverstripe-dependentdropdownfield

包简介

A silverstripe dropdown field that has it's options populated via ajax, based on the value of the field it depends on

README 文档

README

A SilverStripe dropdown field that has its options populated via ajax, based on the value of the field it depends on.

Requirements

SilverStripe 6

Installation

composer require sheadawson/silverstripe-dependentdropdownfield

Usage example

With dropdown field

// 1. Create a callable function that returns an array of options for the DependentDropdownField.
// When the value of the field it depends on changes, this function is called passing the
// updated value as the first parameter ($val)
$datesSource = function($val) {
	if ($val == 'one') {
		// return appropriate options array if the value is one.
	}
	if ($val == 'two') {
		// return appropriate options array if the value is two.
	}
};

$fields = FieldList::create(
	// 2. Add your first field to your field list,
	$fieldOne = DropdownField::create('FieldOneID', 'Field One', ['one' => 'One', 'two' => 'Two']),
	// 3. Add your DependentDropdownField, setting the source as the callable function
	// you created and setting the field it depends on to the appropriate field
	DependentDropdownField::create('FieldTwoID', 'Field Two', $datesSource)->setDepends($fieldOne)
);

With listbox field

// 1. Create a callable function that returns an array of options for the DependentListboxField.
// When the value of the field it depends on changes, this function is called passing the
// updated value as the first parameter ($val)
$datesSource = function($val) {
	if ($val == 'one') {
		// return appropriate options array if the value is one.
	}
	if ($val == 'two') {
		// return appropriate options array if the value is two.
	}
};

$fields = FieldList::create(
	// 2. Add your first field to your field list,
	$fieldOne = ListboxField::create('FieldOneManyManyRelation', 'Field One', [1 => 'One', 2 => 'Two']),
	// 3. Add your DependentListboxField, setting the source as the callable function
	// you created and setting the field it depends on to the appropriate field
	DependentListboxField::create('FieldTwoManyManyRelation', 'Field Two', $datesSource)->setDepends($fieldOne)
);

统计信息

  • 总下载量: 239.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 10
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 28
  • Watchers: 6
  • Forks: 34
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-11-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固