小编Gil*_*ngy的帖子

Sylius定制表格客户

我正在按照Sylius文档上的教程来自定义表单.

这是我有的:

src\AppBundle\Form\Extension\CustomerProfileTypeExtension.php:

<?php

 namespace AppBundle\Form\Extension;

use Sylius\Bundle\CustomerBundle\Form\Type\CustomerProfileType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;


final class CustomerProfileTypeExtension extends AbstractTypeExtension
{
/**
 * {@inheritdoc}
 */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
    // Adding new fields works just like in the parent form type.
    $builder->add('contactHours', TextType::class, [
        'required' => false,
        'label' => 'app.form.customer.contact_hours',
    ]);

    // To remove a field from a form simply call ->remove(`fieldName`).
    // $builder->remove('gender');

    // You can change the label by adding again the same field with …
Run Code Online (Sandbox Code Playgroud)

php symfony sylius

0
推荐指数
1
解决办法
376
查看次数

标签 统计

php ×1

sylius ×1

symfony ×1