valantic / pimcore-forms

Pimcore表单

安装次数: 5,587

依赖项: 0

建议者: 0

安全: 0

星标: 4

关注者: 10

分支: 0

开放问题: 1

类型:pimcore-bundle

3.0.0 2024-03-05 14:15 UTC

README

Latest Version on Packagist Software License PHP Checks

不提供支持!

此包由valantic CEC Schweiz开发,目前正在积极开发中。

设置

composer require valantic/pimcore-forms

然后,在Pimcore管理UI中激活此插件。

用法

配置:app/config/forms.yml

valantic_pimcore_forms:
  forms:
    contact:
      outputs:
        mail:
          type: email
          options:
            to: info@example.com
            document: /system/emails/
        pimcore_object:
          type: data_object
          options:
            class: ContactFormSubmission
            path: '/Forms'
      fields:
        name:
          type: TextType
          options:
            label: Name
          constraints:
            - NotBlank
        email:
          type: EmailType
          options:
            label: Email
          constraints:
            - NotBlank
            - Email
        message:
          type: TextareaType
          options:
            label: Message
          constraints:
            - NotBlank
            - Length:
                min: 20
        submit:
          type: SubmitType

Areabrick

提供Areabrick以用于CMS文档。

控制器 + Twig

动作

public function contactAction(\Valantic\PimcoreFormsBundle\Service\FormService $formService): \Symfony\Component\HttpFoundation\Response
{
    return $this->render('contact_form.html.twig', [
        'form' => $formService->buildForm('contact')->createView(),
    ]);
}

Twig

{% include '@ValanticPimcoreForms/form.html.twig' %}

Twig (HTML)

{% include '@ValanticPimcoreForms/form.html.twig' with {'form': valantic_form_html('contact')} %}

Twig (JSON)

{% include '@ValanticPimcoreForms/form.html.twig' with {'form': valantic_form_json('contact')} %}