becklyn/rad

用于在 Symfony 中使用的 RAD 相关功能。

安装次数: 8,913

依赖项: 4

建议者: 1

安全性: 0

星星: 1

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

8.6.1 2022-02-23 13:26 UTC

This package is auto-updated.

Last update: 2024-09-23 19:16:32 UTC


README

此包为在 Symfony 中使用提供 RAD 相关功能。

⚠️ 新的 Composer 包名

此包已被重命名为 becklyn/rad(v8.0 版本),从 becklyn/rad-bundle 更名。7.x 版本以下仍可在 becklyn/rad-bundle 下找到。

AJAX 协议

此包使用默认的 AJAX 协议,该协议在 AjaxResponseBuilder 中使用,也可用于您的项目。AJAX 调用将始终返回错误 200,因为它不应该使错误跟踪(错误 400 AJAX 请求)过载。

协议如下所示

interface AjaxResponse
{
    /**
     * Whether the call succeeded.
     */
    ok: boolean;

    /**
     * Any string status, like "ok" or "invalid-id" that
     * you can react to in your code (if you need to).
     */
    status: string;

    /**
     * The response data.
     */
    data: Record<number|string, any> | Array<any>;

    /**
     * A redirect target, where the AJAX handler should 
     * redirect to.
     */
    redirect?: string;

    /**
     * A toast message with optional type and action target.
     */
    message?: {
        text: string;
        impact: "positive" | "negative" | "neutral";
        action?: {
            label: string;
            url: string;
        };
    };
}

mojave 中有相应的 fetch 客户端实现,可以使用。上述类型在 mojave 中也作为通用 TypeScript 类型提供。

表单扩展

此包自动添加几个表单扩展。

集合标签扩展

此扩展为 Collection 表单字段添加三个额外的可选标签

  • empty_message 在没有条目时显示。
  • entry_add_label 是 "添加条目" 按钮的标签。
  • entry_remove_label 是每个 "删除条目" 按钮的标签。