承接 webfox/silverstripe-dependentdropdownfield 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

webfox/silverstripe-dependentdropdownfield

Composer 安装命令:

composer require webfox/silverstripe-dependentdropdownfield

包简介

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

README 文档

README

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

Based on the module by sheadawson

Requirements

SilverStripe 3

Usage example

DropdownField

$postsSource  = function ($val) {
	/** @var Category $category */
	$category = Category::get_by_id('Category', $val);
	return $category->Posts()->map()->toArray();
};

$currentPost = $this->PostID;

/** @var DependentDropdownField $postField */
$postField = DependentDropdownField::create('AssignedPost', 'Select Featured Post', $postsSource);
$postField->setMultiple(true);
$postField->setDefaultItems($currentPost);
$postField->setDepends($fields->fieldByName('Root.Main.CategoryID'));

$fields->addFieldToTab('Root.Main', $postsField);

ListboxField


$postsSource  = function ($val) {
	/** @var Category $category */
	$category = Category::get_by_id('Category', $val);
	return $category->Posts()->map()->toArray();
};

$currentPosts = $this->Posts()->column('ID');

/** @var DependentListboxField $postsField */
$postsField = DependentListboxField::create('AssignedPosts', 'Select Posts', $postsSource);
$postsField->setMultiple(true);
$postsField->setDefaultItems($currentPosts);
$postsField->setDepends($fields->fieldByName('Root.Main.CategoryID'));

$fields->addFieldToTab('Root.Main', $postsField);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-01-19