商品に追加項目1(add_item1)を追加する。
<?php namespace Customize\Form\Extension\Admin; use Eccube\Form\Type\Admin\ProductType; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\TextType; // use Symfony\Component\Form\Extension\Core\Type\IntegerType; use Symfony\Component\Form\FormBuilderInterface; class ProductTypeExtension extends AbstractTypeExtension { public function getExtendedType() { return ProductType::class; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('add_item1', TextType::class, [ 'required' => false ]); } }
<?php namespace Customize\Entity; use Eccube\Annotation\EntityExtension; use Eccube\Entity\Product; /** * @EntityExtension("Eccube\Entity\Product") */ trait ProductTrait { /** * @var string * * @ORM\Column(name="add_item1", type="string", nullable=true) */ private $add_item1; /** * Set add_item1. * * @param string|null $special_comment * * @return Product */ public function setAddItem1($add_item1) { $this->add_item1 = $add_item1; return $this; } /** * Get add_item1. * * @return string */ public function getAddItem1() { return $this->add_item1; } }
cd /var/www/public_html/[EC-CUBEインストールディレクトリ] php bin/console eccube:generate:proxies php bin/console cache:clear --no-warmup php bin/console doctrine:schema:update --dump-sql --force
<div class="row"> <div class="col-3"> <div class="d-inline-block" data-tooltip="true" data-placement="top" title="{{ 'tooltip.admin.product.add_item1'|trans }}"> <span>{{ 'admin.product.add_item1'|trans }}</span> <i class="fa fa-question-circle fa-lg ml-1"></i> </div> </div> <div class="col mb-2"> <div> {{ form_widget(form.add_item1) }} {{ form_errors(form.add_item1) }} </div> </div> </div>
admin.product.add_item1: 追加項目1 tooltip.admin.product.add_item1: 追加項目1を設定します。