maxpowel/wixet-recaptcha-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maxpowel/wixet-recaptcha-bundle

Composer 安装命令:

composer require maxpowel/wixet-recaptcha-bundle

包简介

This Bundle provides support for google recaptcha into symfony forms

README 文档

README

Build Status Coverage Status License

Add google captcha validation to symfony forms easily

Installation

Step 1: Use composer and enable Bundle

To install WixetRecaptchaBundle with Composer just type in your terminal:

composer require maxpowel/wixet-recaptcha-bundle

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Wixet\RecaptchaBundle\WixetRecaptchaBundle(),
    // ...
);

Step2: Configure the bundle's

Add the following to your config file:

wixet_recaptcha:
     site_key: "YourSiteKey"
     secret: "YourSecret"

Get your recaptcha keys at https://www.google.com/recaptcha/admin

Basic Usage

In your controller or wherever is your form, add the WixetRecaptchaType like the following example:

$form = $this->createFormBuilder()
            ->add("name", TextType::class)
            ->add("recaptcha", WixetRecaptchaType::class)
            ->add("Submit", SubmitType::class)
            ->getForm()
        ;

Don't forget to include the type

use Wixet\RecaptchaBundle\Form\Type\WixetRecaptchaType;

Multiple and delayed rendering

Sometimes you need multiple recaptchas or delayed render (not render onload but render when you want). This is useful for example when you load ajax content with recaptchas.

The first step is include the recaptcha script manually (where you load all your scripts), you have to options:

{{ include_recaptcha() | raw }}

or

{{ include('WixetRecaptchaBundle::recaptcha_explicit.html.twig', { 'site_key': recaptcha_site_key() }) }}

I prefer the first way but the second allows more customization.

Now render the form as usual but with the option "explicit_render=true"

$form = $this->createFormBuilder()
            ->add("name", TextType::class)
            ->add("recaptcha", WixetRecaptchaType::class, array(
                'explicit_render' => true
            ))
            ->add("Submit", SubmitType::class)
            ->getForm()
        ;

That's all!

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固