埋め込みフォームを作成します。ItemType.phpでdbの名前でラベルを付けるにはどうすればよいですか?
1.)いいね:
$builder->add('id', 'checkbox', array('label'=> $v->getName(),...
2.)ちなみに、symfony2はItemType.phpごとに数値0,1,2をレンダリングします。どうすればそれを取り除くことができますか?
私の行動:
$task = new UserFriends();
foreach ($fb_friends as $k => $v) {
$name = $v->getName();
$friend_id = $v->getFriendId();
$id = $v->getId();
$t = new Item();
$t->name = $name;
$t->friendId = $friend_id;
$t->id = $id;
$task->getId()->add($t);
}
$form = $this->createForm(new CreateRequest(), $task, array());
CreateRequest.php-formの一部:
$builder->add('id', 'collection', array('type' => new ItemType(),
私のItemType.phpの一部
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('id', 'checkbox', array('label'=> 'Name', 'required' => false, 'mapped' => false));
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Frontend\ChancesBundle\Entity\Item',
));
}
public function getName()
{
return 'item';
}
そして私のItem.php-Entityの一部
class Item
{
public $id;
public $friendId;
public $name;
public function getFriendId()
{
return $this->friendId;
}