becklyn/rad-bundle

此包已被弃用且不再维护。作者建议使用 becklyn/rad 包。

此包提供基本组件

安装次数: 6,378

依赖项: 1

建议者: 1

安全性: 0

星标: 4

关注者: 2

分支: 3

开放问题: 0

类型:symfony-bundle

8.0.0 2022-12-15 13:51 UTC

README

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

becklyn/rad-bundle <= v7 已弃用,并由 becklyn/rad v8+ 替代。

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 是每个“删除条目”按钮的标签。