{"id":268,"date":"2021-09-18T14:23:30","date_gmt":"2021-09-18T05:23:30","guid":{"rendered":"http:\/\/syrup-factory.com\/memo\/?p=268"},"modified":"2022-06-06T10:25:30","modified_gmt":"2022-06-06T01:25:30","slug":"eccube4-%e5%95%86%e5%93%81%e3%81%ab%e3%83%9e%e3%82%a4%e3%83%8a%e3%82%b9%e4%be%a1%e6%a0%bc%e3%82%92%e8%a8%ad%e5%ae%9a%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/syrup-factory.com\/memo\/archives\/268","title":{"rendered":"Eccube4 \u5546\u54c1\u306b\u30de\u30a4\u30ca\u30b9\u4fa1\u683c\u3092\u8a2d\u5b9a\u3059\u308b"},"content":{"rendered":"\n<p>Eccube4 \u306e\u5546\u54c1\u306e\u4fa1\u683c Eccube\\Form\\Type\\PriceType \u3067\u306f0\u4ee5\u4e0a\u306e\u6570\u5024\u306e\u307f\u304c\u8a2d\u5b9a\u3067\u304d\u308b\u3002<br>\n\u30de\u30a4\u30ca\u30b9\u4fa1\u683c\u306f\u30a8\u30e9\u30fc\u3068\u306a\u308b\u3002<br>\n\u30de\u30a4\u30ca\u30b9\u4fa1\u683c\u3092OK\u3068\u3059\u308b\u306b\u306f\u3001form\u306eextension\u3067\u4fa1\u683c\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u8a2d\u5b9a\u3092\u4e0a\u66f8\u304d\u3059\u308c\u3070\u3088\u3044\u3002<br>\n\u30fb\u30aa\u30d7\u30b7\u30e7\u30f3\u300c&#8217;accept_minus&#8217; => true\u300d\u3068\u3057\u3001<br>\n\u30fb\u5024\u30c1\u30a7\u30c3\u30af\u306emin\u3092 0 \u3067\u306a\u304f\u30de\u30a4\u30ca\u30b9\u5024\u306b\u3059\u308b\u3002<br>\n\n<p>app\\Customize\\Form\\Extension\\Admin\\ProductClassFormExtension.php<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\nnamespace Customize\\Form\\Extension\\Admin;\n\nuse Doctrine\\ORM\\EntityManagerInterface;\nuse Eccube\\Common\\EccubeConfig;\nuse Eccube\\Form\\Type\\Admin\\ProductClassType;\nuse Symfony\\Component\\Form\\AbstractTypeExtension;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\nuse Symfony\\Component\\Form\\FormEvent;\nuse Symfony\\Component\\Form\\FormEvents;\nuse Eccube\\Form\\Type\\PriceType;\nuse Symfony\\Component\\Validator\\Constraints as Assert;\n\n\/**\n * Class ProductClassFormExtension .\n *\/\nclass ProductClassFormExtension extends AbstractTypeExtension\n{\n    \/**\n     * @var EccubeConfig\n     *\/\n    private $eccubeConfig;\n\n    \/**\n     * @var EntityManagerInterface\n     *\/\n    private $entityManager;\n\n    public function __construct(EccubeConfig $eccubeConfig, EntityManagerInterface $entityManager)\n    {\n        $this-&gt;eccubeConfig = $eccubeConfig;\n        $this-&gt;entityManager = $entityManager;\n    }\n\n    \/**\n     * RelatedCollectionExtension.\n     *\n     * @param FormBuilderInterface $builder\n     * @param array $options\n     *\/\n    public function buildForm(FormBuilderInterface $builder, array $options)\n    {\n            $builder\n                \/\/ \u30de\u30a4\u30ca\u30b9\u4fa1\u683c\u3092\u8a31\u5bb9\u3059\u308b\n                -&gt;add(&#039;price02&#039;, PriceType::class, [\n                    &#039;required&#039; =&gt; true,\n                    &#039;accept_minus&#039; =&gt; true,\n                    &#039;constraints&#039; =&gt; [\n                        new Assert\\Length([&#039;min&#039; =&gt; (-1) * $this-&gt;eccubeConfig[&#039;eccube_price_len&#039;], &#039;max&#039; =&gt; $this-&gt;eccubeConfig[&#039;eccube_price_len&#039;]]),\n                    ],\n                ]) \n\n                -&gt;add(&#039;price01&#039;, PriceType::class, [\n                    &#039;required&#039; =&gt; false,\n                    &#039;accept_minus&#039; =&gt; true,\n                    &#039;constraints&#039; =&gt; [\n                        new Assert\\Length([&#039;min&#039; =&gt; (-1) * $this-&gt;eccubeConfig[&#039;eccube_price_len&#039;], &#039;max&#039; =&gt; $this-&gt;eccubeConfig[&#039;eccube_price_len&#039;]]),\n                    ],\n                ]) \n\n        ;\n    }\n    \/**\n     * product admin form name.\n     *\n     * @return string\n     *\/\n    public function getExtendedType()\n    {\n        return ProductClassType::class;\n    }\n\n\n    \/**\n     * product admin form name.\n     *\n     * @return string[]\n     *\/\n    public static function getExtendedTypes()\n    {\n        return [ProductClassType::class];\n    }\n}\n<\/pre>\n\n<p>\u8ffd\u8a18\uff1a\u7ba1\u7406\u753b\u9762\u306e\u65b9\u3067\u30011\u304b\u6240\u3060\u3051\u672c\u4f53\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4fee\u6b63\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u3002\u3069\u3046\u3057\u3066\u3082\u56de\u907f\u3067\u304d\u305a\u30fb\u30fb\u30fb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eccube4 \u306e\u5546\u54c1\u306e\u4fa1\u683c Eccube\\Form\\Type\\PriceType \u3067\u306f0\u4ee5\u4e0a\u306e\u6570\u5024 &#8230;<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/syrup-factory.com\/memo\/archives\/268\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/posts\/268"}],"collection":[{"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":8,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/posts\/268\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/syrup-factory.com\/memo\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}