0
Symfony2에서 유형 클래스의 필드 이름을 사용자 정의 할 수있는 방법이 있습니까?Symfony2에서 양식 필드 이름 사용자 정의
<?php
// src/Fuz/TypesBundle/Form/Editor/GeneralType.php
namespace Fuz\TypesBundle\Form\Editor;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Fuz\TypesBundle\Entity\Editor\GeneralData;
class GeneralType extends AbstractType
{
/**
* Root node ID
*
* @access private
* @var rootId
*/
private $rootId;
/**
* Current node ID
*
* @access private
* @var rootId
*/
private $currentId;
/**
* Constructor
*
* @access public
* @param string $rootId
* @param string $currentId
*/
public function __construct($rootId, $currentId)
{
$this->rootId = $rootId;
$this->currentId = $currentId;
}
/**
* General form fields
*
* @access public
* @param FormBuilder $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('useField', 'text',
array (
'required' => false,
'label' => 'types.general.use_field',
'read_only' => ($this->rootId == $this->currentId),
'attr' => array(
'name' => "useField{$this->currentId}",
)
));
// ...
}
/**
* Form name
*
* @access public
* @return string
*/
public function getName()
{
return 'General';
}
}
그러나 (일반 내 양식 이름) 내 필드는 여전히 General[useField]
이름을 가진 :
나는 또한 유효성 확인을 계속하고 싶습니다.