erikgreasy/wp-advanced-forms 问题修复 & 功能扩展

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

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

erikgreasy/wp-advanced-forms

最新稳定版本:v0.1.2

Composer 安装命令:

composer require erikgreasy/wp-advanced-forms

包简介

This is my package wp-advanced-forms

README 文档

README

Latest Version on Packagist

Advanced forms provide a convenient way to create custom forms in WordPress by making typical form tasks like validation easier.

Current batteries included

  • ability to use laravel validation
  • easy way to config your form without hassle of repeating WP action key, ugly WP hooks callbacks for handling forms and more

Installation

You can install the package via composer:

composer require erikgreasy/wp-advanced-forms

Usage

Create your forms classes extending the base FormComponent class. Example form class:

<?php

namespace App\Forms;

use Erikgreasy\WpAdvancedForms\FormComponent;

class ContactForm extends FormComponent
{
    public bool $usesAjax = true;

    public function handleSubmit()
    {
        // This is where we handle our form.
        // We can use provided laravel validator
        $validator = $this->validator->make($_POST, [
            'name' => 'required'
        ]);

        if($validator->fails()) {
            wp_send_json($validator->errors());
        }

        wp_send_json([
            'message' => 'Success'
        ]);
    }

    public function actionName(): string
    {
        return 'contact_form';
    }
}

Register all your forms in functions.php, or in the plugin:

WpAdvancedForms::load([
    ContactForm::class,
]);

Now you can render your forms with single source of truth based in your form class:

<?php
$form = \Erikgreasy\WpAdvancedForms\WpAdvancedForms::getForm(
    \App\Forms\ContactForm::class
);
?>

{!! $form->openForm() !!}
    
    <input type="text" name="name">

    <button>Submit</button>
{!! $form->closeForm() !!}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-24