aamant/configurable-attributes-bundle

Configurable attributes for Symfony

1.0.0 2017-03-22 07:43 UTC

This package is not auto-updated.

Last update: 2024-11-10 02:31:39 UTC


README

Install

Install with composer

composer require aamant/configurable-attributes-bundle

Modify AppKernel.php

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

Add routes

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

Use

Add relation to entity

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

Form field

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