Backend\Modules\ContentBlocks\Form\ContentBlockType::buildForm PHP Method

buildForm() public method

public buildForm ( Symfony\Component\Form\FormBuilderInterface $builder, array $options )
$builder Symfony\Component\Form\FormBuilderInterface
$options array
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('title', TextType::class, ['required' => true, 'label' => 'lbl.Title'])->add('text', EditorType::class, ['required' => true, 'label' => 'lbl.Content']);
        $templates = $this->getPossibleTemplates();
        // if we have multiple templates, add a dropdown to select them
        if (count($templates) > 1) {
            $builder->add('template', ChoiceType::class, ['required' => true, 'label' => 'lbl.Template', 'choices' => $templates, 'choice_translation_domain' => false]);
        }
        $isVisibleOptions = ['label' => 'lbl.VisibleOnSite', 'required' => false];
        if (!array_key_exists('data', $options)) {
            $isVisibleOptions['attr']['checked'] = 'checked';
        }
        $builder->add('isVisible', CheckboxType::class, $isVisibleOptions);
    }