Skip to content

Instantly share code, notes, and snippets.

@abfan1127
Last active April 24, 2019 06:12
Show Gist options
  • Save abfan1127/3213da57da9ead7237d04c483327904e to your computer and use it in GitHub Desktop.
Save abfan1127/3213da57da9ead7237d04c483327904e to your computer and use it in GitHub Desktop.
PHP issue
// in Controller
$form = $this->createForm(new Type\AnimalAdminType($animal), $animal);
// in AnimalAdminType
$builder->add('animal_photos', 'collection', array(
'type' => new \Fftdev\RescueBundle\Form\Type\AnimalPhotoAdminType(),
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
));
// in AnimalPhotoAdminType
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Fftdev\RescueBundle\Model\AnimalPhoto',
));
}
// in AnimalPhoto
public function postSave(\PropelPDO $con = null) {
...
moves photos and saves name to databse
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment