opifer/form-bundle
最新稳定版本:0.1.4
Composer 安装命令:
composer require opifer/form-bundle
包简介
Opifer Form Bundle
README 文档
README
Opifer FormBundle
Installation
Add OpiferForm to your composer.json:
$ composer require opifer/form-bundle "~0.1"
Register the bundle in app/AppKernel.php:
public function registerBundles() { $bundles = array( // ... new Opifer\EavBundle\OpiferEavBundle(), new Opifer\FormBundle\OpiferFormBundle() ); }
Install the OpiferEavBundle according to its documentation.
Extend the Form & Post models;
namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Opifer\FormBundle\Model\Form as BaseForm; /** * @ORM\Entity() * @ORM\Table(name="form") */ class Form extends BaseForm { }
namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Opifer\EavBundle\Model\EntityInterface; use Opifer\FormBundle\Model\Post as BasePost; /** * @ORM\Entity() * @ORM\Table(name="post") */ class Post extends BasePost implements EntityInterface { }
Define these in the config along with your admin email:
opifer_form: from_email: noreply@yourcompany.com form: class: AppBundle\Entity\Form post: class: AppBundle\Entity\Post
To be able to manage and use your forms, add some routes to your app/config/routing.yml:
opifer_form: resource: "@OpiferFormBundle/Resources/config/routing.yml" opifer_form_admin: resource: "@OpiferFormBundle/Resources/config/routing_admin.yml" prefix: /admin
Usage
Once you created your forms in your admin panel, you might want to display them on the frontend. To do this, you'd have to create a controller action that retrieves the form and displays it on the frontend
namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class PageController extends Controller { public function contactAction() { $form = $this->get('opifer.form.form_manager')->getRepository()->find(1); return $this->render('Page/contact.html.twig', array( 'form' => $form )); } }
{# app/Resources/views/Page/contact.html.twig #} {% set form = create_form_view(form) %} {{ form_start(form) }} {{ form_widget(form) }} <input type="submit" value="save"> {{ form_end(form) }}
统计信息
- 总下载量: 1.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-08-20