Advertisement
stixlink

Untitled

May 31st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.96 KB | None | 0 0
  1.  
  2. /**
  3.  * Class RankingConditionAdmin
  4.  */
  5. class RankingConditionsAdmin extends AbstractAdmin
  6. {
  7.  
  8.     /**
  9.      * {@inheritdoc}
  10.      */
  11.     protected function configureListFields(ListMapper $list)
  12.     {
  13.         $list->add('ctrMax', NumberType::class);
  14.     }
  15.  
  16.     /**
  17.      * {@inheritdoc}
  18.      */
  19.     protected function configureFormFields(FormMapper $form)
  20.     {
  21.  
  22.         $form
  23.             ->add('ctrMax', NumberType::class)
  24.             ->add('ctrMin', NumberType::class)
  25.             ;
  26.     }
  27. }
  28.  
  29. class RankingAdmin extends AbstractAdmin
  30. {
  31.     protected $baseRoutePattern = 'ranking';
  32.  
  33.     /**
  34.      * @param mixed $object
  35.      *
  36.      * @return string
  37.      */
  38. //    public function toString($object)
  39. //    {
  40. //        return sprintf("%s", $object->getName());
  41. //    }
  42.  
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     protected function configureListFields(ListMapper $list)
  47.     {
  48.         $list->add('name', TextType::class)
  49.              ->add(
  50.                  '_action',
  51.                  'actions', [
  52.                      'actions' => [
  53.                          'edit' => [],
  54.                      ],
  55.                  ]
  56.              );
  57.     }
  58.  
  59.     /**
  60.      * {@inheritdoc}
  61.      */
  62.     protected function configureFormFields(FormMapper $form)
  63.     {
  64.         $form
  65.             ->tab('General')->with('');
  66.         $form
  67.             ->add('name', TextType::class)
  68.             ->add('defaultCtrMax', NumberType::class, array(
  69.                 'required' => true,
  70.             ))
  71.             ->add('defaultCtrMin', NumberType::class, array(
  72.                 'required' => true,
  73.             ))
  74.             ->add('defaultConversionMax', NumberType::class, array(
  75.                 'required' => true,
  76.             ))
  77.             ->add('defaultConversionMax', NumberType::class, array(
  78.                 'required' => true,
  79.             ))
  80.             ->end()
  81.             ->end()
  82.             ->tab('Conditions')
  83.             ->with('');
  84.         $form
  85.             ->add(
  86.                 'rankingConditions',
  87.                 CollectionType::class,
  88.                 array(
  89.                     'type_options' => array(
  90.                         // Prevents the "Delete" option from being displayed
  91.                         'delete' => false,
  92.                         'delete_options' => array(
  93.                             // You may otherwise choose to put the field but hide it
  94.                             'type'         => 'hidden',
  95.                             // In that case, you need to fill in the options as well
  96.                             'type_options' => array(
  97.                                 'mapped'   => false,
  98.                                 'required' => false,
  99.                             )
  100.                         )
  101.                     )
  102.                 ), array(
  103.                     'edit' => 'inline',
  104.                     'inline' => 'table',
  105.                     'sortable' => 'position',
  106.                 ))
  107.             ->end()->end();
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement