php - Symfony Sonata admin find by some field -
i install sonataadminbundle , create controller extends admin , function configureformfields, configuredatagridfilters, configurelistfields. , in field list use field image see url image, image live in amazon s3 want see image in table. how this? , have filter find colums, entity developer have array skill , 1 skill find how find 2 or many skill ?
and add admin can upload avatar developer in action(not extends admin) upload for(field image in developer = string , set url s3)
$url = sprintf( '%s%s', $this->container->getparameter('acme_storage.amazon_s3.base_url'), $this->getphotouploader()->upload($request->files->get('file'), $user_company_name) ); $user->setimage($url);
how can sonata, reload controller? how ?
this action:
class developeradmin extends admin { protected function configureformfields(formmapper $formmapper) { $formmapper ->add('firstname', null, array('label' => 'developer\'s first name', 'max_length' => 255)) ->add('lastname', null, array('label' => 'developer\'s last name', 'max_length' => 255)) ->add('qualification', 'choice', array('label' => 'speciality', 'choices' => array('frontend' => 'frontend', 'backend' => 'backend', 'full stack' => 'full stack'),'attr'=> array('class'=>'qualif'), 'required' => false)) ->add('level', 'choice', array('label' => 'professional level', 'max_length' => 255, 'choices' => array('junior' => 'junior', 'middle' => 'middle', 'senior' => 'senior'))) ->add('tags', 'tags', array('label' => 'tags','required' => false)) ->add('main_skill', 'mainskill', array('label' => 'main skill', 'required' => true, 'mapped' => true, 'attr' => array('placeholder' => 'select skills ...', 'class'=>'main_skill') )) ->add('skills', 'skills', array('label' => 'skills','required' => false)) ->add('english', 'choice', array('label' => 'english level', 'max_length' => 255, 'choices' => array('basic' => 'basic', 'intermediate' => 'intermediate', 'advanced' => 'advanced'))) ->add('rate', null, array('label' => 'rate $/h', 'max_length' => 255)); $image = $this->getsubject(); $filefieldoptions = array('required' => false); if ($image && ($webpath = $image->getimage())) { dump($image);exit; //i have user , field image local url /temp/sdgsdg $container = $this->getconfigurationpool()->getcontainer(); $fullpath = $container->get('request')->getbasepath().'/'.$webpath; $filefieldoptions['help'] = '<img src="'.$fullpath.'" class="admin-preview" />'; } $formmapper ->add('image', 'file', $filefieldoptions) } protected function configuredatagridfilters(datagridmapper $datagridmapper) { $datagridmapper ->add('firstname') ->add('lastname') ->add('main_skill') ->add('skills') ; } protected function configurelistfields(listmapper $listmapper) { $listmapper ->addidentifier('id') ->add('username') ->add('firstname') ->add('lastname') ->add('main_skill') ->add('skills') ->add('image', 'string', array('template' => 'sonatamediabundle:mediaadmin:list_image.html.twig')) ->add('_action', 'actions', array( 'actions' => array( 'show' => array(), 'edit' => array(), ) )) ; }
}
how find 2 or many skill ???? entity:
class developer extends customuser { /** * @var string * * @orm\column(name="email", type="string", length=255, unique=false, nullable=true) * @assert\length(min=3, max=255) */ protected $email; //// /** * @var string * * @orm\column(name="skills", type="array") */ private $skills = array();
and in table developer in colum skill see:
[0 => soap] [1 => cisco] [2 => php] [3 => sugar crm] [4 => hibernate] [5 => java me]
but when add developer use service skill , see norm skill:
xphp, xjava
how can fix problem, reload template or controller ? please
for task use https://sonata-project.org/bundles/media/2-2/doc/index.html . it's easy
Comments
Post a Comment