Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Admin;
  3. use Zitec\RuleEngineBundle\Form\Type\RuleEngineType;
  4. use Zitec\RuleEngineBundle\Form\Type\PostconditionEngineType;
  5. use Sonata\AdminBundle\Admin\AbstractAdmin;
  6. use Sonata\AdminBundle\Datagrid\ListMapper;
  7. use Sonata\AdminBundle\Form\FormMapper;
  8. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  9. /**
  10. * Class RuleAdmin
  11. */
  12. class PostconditionAdmin extends RuleAdmin
  13. {
  14. /**
  15. * @param FormMapper $formMapper
  16. */
  17. protected function configureFormFields(FormMapper $formMapper)
  18. {
  19. $fieldOptions = ['label' => false];
  20. $parentOptions = $this->getParentFieldDescription()->getOptions();
  21. if (!isset($parentOptions['rule_manager'])) {
  22. throw new \RuntimeException('Missing rule manager object!');
  23. }
  24. $fieldOptions['rule_manager'] = $parentOptions['rule_manager'];
  25. $formMapper
  26. ->with('General', ['class' => 'col-md-12'])
  27. ->add('active')
  28. ->add('name')
  29. ->end()
  30. ->with('Reglas', ['class' => 'col-md-12'])
  31. ->add('ruleObject', PostconditionEngineType::class, $fieldOptions)
  32. ->end()
  33. ->with('Acciones', [
  34. 'class' => 'col-md-12',
  35. 'box_class' => 'box box-solid box-success custom-form-fields',
  36. 'description' => 'Acciones a realizar',
  37. ])
  38. ->add('action', HiddenType::class,array('attr'=>array("hidden" => true)))
  39. ->end()
  40. ->end();
  41. }
  42. }