eltharin/automaticcollection 问题修复 & 功能扩展

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

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

eltharin/automaticcollection

最新稳定版本:V1.5.0

Composer 安装命令:

composer require eltharin/automaticcollection

包简介

automaticcollection Bundle for symfony

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

  • Require the bundle with composer:
composer require eltharin/automaticcollection

You can use eltharin/twigfilesgetter for load unique Js : https://github.com/eltharin/TwigFilesGetter

In this case, you just have to write {{ get_required_js_files() }} in your twig base template to load JS file.

Otherwise you have to import /bundles/eltharinautomaticcollection/js/automaticcollection.js manually

What is AutomaticCollection Bundle?

This bundle will render automatic add and delete elements for Collection Type.

When allow_add param will be set, the bundle will automaticly add a button for add a new row.

When allow_delete param will be set the bundle will automaticly add a delete row button on each line,

When allow_delete param is not set, you can have the delete button only for the new rows.

Use It :

As CollectionType, You have two Form Types:

PrincipalType :

class PrincipalType extends AbstractType
{
	public function buildForm(FormBuilderInterface $builder, array $options): void
	{
		$builder
			->add('numero')
			->add('libelle')
			->add('users', AutomaticCollectionType::class, [
						'entry_type' =>  SecondType::class,
						'allow_add' => true,
						'allow_delete' => true,
						'by_reference' => false,
						'add_button_string' => '<button type="button" class="automatic_collection_addBtn" data-collection-holder-class="{{ id }}">New</button>',
						'delete_button_string' => '<button type="button" class="btn danger automatic_collection_delBtn">Suppr</button>'
					]);
		;
	}

	public function configureOptions(OptionsResolver $resolver): void
	{
		$resolver->setDefaults([
			'data_class' => null,
		]);
	}
}

And SecondType :

class SecondType extends AbstractType
{
	public function buildForm(FormBuilderInterface $builder, array $options): void
	{
		$builder
			->add('lastname')
			->add('surname')
		;
	}

	public function configureOptions(OptionsResolver $resolver): void
	{
		$resolver->setDefaults([
			'data_class' => null,
		]);
	}
}

In PrincipalType, the options allow_add and allow_delete (from CollectionType) will automaticlly add buttons add and delete on each row.

When you add a new row, the button delete will be shown no matter that the allow_delete is at true.

you can change HTML button by replacing twig templates in your form template site or in same template :

{# if in same view don't forget this line to enable it #}
{% form_theme form _self %} 

{%- block automatic_collection_add_button_widget -%}
    <button type="button" class="automatic_collection_addBtn" data-collection-holder-class="{{ id }}">New</button>
{%- endblock automatic_collection_add_button_widget -%}

{%- block automatic_collection_delete_button_widget -%}
    <button type="button" class="btn danger automatic_collection_delBtn">Suppr</button>
{%- endblock automatic_collection_delete_button_widget -%}

don't forget to add classes automatic_collection_addBtn and automatic_collection_delBtn for JS and data-collection-holder-class="{{ id }}"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2022-08-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固