Hi,
How can I create a
Custom Form Field Type with
json_array.
I just want to save a couple of information.
Ex :
["key":"78915547","secret_key":"75845", "public_key":"78945"...]
Admin Class:protected function configureFormFields(FormMapper $formMapper) {
$formMapper ->add('extra_params', 'extra_param_collection', array(
'allow_add' => true,
))...
Custom Form Type :
<?php
namespace Application\Sonata\UserBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormBuilderInterface;
class ExtraParamCollectionType extends AbstractType {
public function getParent() {
return 'collection';
}
public function getName() {
return 'extra_param_collection';
}
}
Service :
extra_param_collection:
class: Application\Sonata\UserBundle\Form\Type\ExtraParamCollectionType
tags:
- { name: form.type }
Entity:
/**
* @var string
*
* @ORM\Column(type="json_array", length=512, nullable=true)
*/
private $extra_params;
How i can display in my form many fields and how to save it in this format?
Thank you in advance