Skip to content

Commit

Permalink
Merge pull request #6 from pascalwacker/patch-1
Browse files Browse the repository at this point in the history
Enable custom form fields
  • Loading branch information
Alsatian67 committed Aug 5, 2016
2 parents 24ffabc + 8695302 commit c0414b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Form/Extensions/ExtensibleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ public static function getSubscribedEvents()

private function getListenedType(ResolvedFormTypeInterface $type)
{
$return = array(
'original' => get_class($type->getInnerType())
);
while($type){
if(in_array(get_class($type->getInnerType()),$this->enabledTypes)){
return get_class($type->getInnerType());
$return['type'] = get_class($type->getInnerType());
return $return;
}

$type = $type->getParent();
Expand All @@ -67,6 +71,8 @@ public function populateAjaxChoices(FormEvent $event)

private function populateAjaxChoice(FormEvent $event,$childName, $type)
{
$original = $type['original'];
$type = $type['type'];
$form = $event->getForm();
$child = $form->get($childName);
$options = $child->getConfig()->getOptions();
Expand Down Expand Up @@ -109,10 +115,10 @@ private function populateAjaxChoice(FormEvent $event,$childName, $type)
}

// Since line 72 is returning all resolved option, only these options are reused :
$newOptions = array('constraints'=>$options['constraints'],'choice_label'=>$options['choice_label'],'route'=>$options['route'],'route_params'=>$options['route_params'],'required'=>$options['required'],'multiple'=>$options['multiple'],'choices'=>$choices);
$newOptions = array('constraints'=>$options['constraints'],'choice_label'=>$options['choice_label'],'route'=>$options['route'],'route_params'=>$options['route_params'],'required'=>$options['required'],'multiple'=>$options['multiple'],'choices'=>$choices,'attr'=>$options['attr']);

if(array_key_exists('class',$options)){$newOptions=array_merge($newOptions,array('class'=>$options['class']));}
$form->add($childName,$type,$newOptions);
$form->add($childName,$original,$newOptions);
}

private function addChoice(&$array,$data,$class,$type){
Expand Down

0 comments on commit c0414b6

Please sign in to comment.