aamant/configurable-attributes-bundle

Symfony的可配置属性

1.0.0 2017-03-22 07:43 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:56:51 UTC


README

安装

使用composer安装

composer require aamant/configurable-attributes-bundle

修改AppKernel.php

$bundles = [
    ...
    new Aamant\ConfigurableAttributesBundle\AamantConfigurableAttributesBundle(),
    ...
];

添加路由

configurable_attributes.attributes:
    resource: "@AamantConfigurableAttributesBundle/Resources/config/routing.xml"

使用

添加实体关系

/**
 * @ORM\ManyToOne(targetEntity="\Aamant\ConfigurableAttributesBundle\Entity\Option")
 * @ORM\JoinColumn(name="relation_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
 */
private $relation;

表单字段

$builder
    ...
    ->add('relation', \Aamant\ConfigurableAttributesBundle\Form\AttributeOptionType::class, [
        'definition'    => 'test',
        'placeholder'   => '',
        'required'      => false,
    ])
    ...
;