PHP code example of braunstetter / control-panel-bundle

1. Go to this page and download the library: Download braunstetter/control-panel-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

braunstetter / control-panel-bundle example snippets




namespace App\Form;

use App\Entity\OrangePuppy;
use Braunstetter\ControlPanel\Form\PageType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrangePuppyType extends PageType
{
    public function buildBodyForm(FormInterface $builder, array $options)
    {
        $builder
            ->add('title');
    }

    public function buildSidebarForm(FormInterface $builder, array $options)
    {
        $builder->add('sideBox', TestBoxType::class);
    }

    public function buildToplineRightForm(FormInterface $builder, array $options)
    {
        $builder->add('submit', SubmitType::class, ['attr' => ['class' => 'cp-button-default']]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'title' => 'Create a new OrangePuppy',
            'data_class' => OrangePuppy::class,
        ]);
    }

    public function getParent()
    {
        return PageType::class;
    }
}



namespace App\Form;

use Braunstetter\ControlPanel\Form\BoxType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

class TestBoxType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('description', TextType::class);
    }

    public function getParent(): string
    {
       return BoxType::class;
    }
}