如何为CakePHP 4中的Bootstrap-UI 3设置默认对齐方式?

发布于 2025-01-26 20:40:45 字数 851 浏览 5 评论 0原文

这是关于CakePHP的Boostrap-UI插件的一个特别晦涩的问题,但我希望有人可以提供帮助。

我正在使用bootstrap-ui( https://github.com/friendsofcake/bootstrap-bootstrap-ui )版本3.0,因此使用Bootstrap 4.6。

我正在尝试创建一个具有控制的控件的表单,该表格与他们的标签保持在此处的示例 -

“在此处输入映像说明”

我看不到如何定义默认列分发即,标签和控制容器的类是col-4col-8,而没有任何断点。

如果我尝试类似的事情 -

              'align' => [
                'left' => 4,
                'middle' => 8,
              ]

创建的类是col-md-4col-md-8 ie,似乎默认为MD作为列的断点。

我知道这有点晦涩,但是有人知道如何做我想做的事吗?

This is a particularly obscure question about the Boostrap-UI plugin for CakePHP but I'm hoping someone might be able to help.

I’m using Bootstrap-UI (https://github.com/FriendsOfCake/bootstrap-ui) version 3.0, so using Bootstrap 4.6.

I’m trying to create a form that has controls that are aligned horizontally with their labels using the example from the readme here -

enter image description here

This works fine except I can’t see how to define the default column distribution ie so that the classes for the label and the control container are something like col-4 and col-8 without any breakpoint defined.

If I try something like -

              'align' => [
                'left' => 4,
                'middle' => 8,
              ]

The classes created are col-md-4 and col-md-8 ie it seems to default to md as the breakpoint for the columns.

I know this is a bit obscure but does anyone have any idea how to do what I want?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只涨不跌 2025-02-02 20:40:45

当前不支持的AFAICT,这意味着您只能生成默认的MB断点或自己指定断点。

您可以在GitHub上打开问题,以获取功能请求。作为解决方法,您可以扩展插件的形式助手和覆盖formHelper :: _ gridclass()以修改生成的类列表,这符合此内容的线条,这将从生成的类字符串中删除默认的断点:

namespace App\View\Helper;

class FormHelper extends \BootstrapUI\View\Helper\FormHelper
{
    protected function _gridClass(string $position, bool $offset = false): string
    {
        return str_replace('-md', '', parent::_gridClass($position, $offset));
    }
}
public function initialize(): void
{
    parent::initialize();

    $this->initializeUI();

    $this->helpers['Form'] = [
        'className' => \App\View\Helper\FormHelper::class
    ];
}

另请参见 https://book.cake.cake.org.org.org.org.org /4/en/views/helpers.html#creating-helpers

AFAICT that's currently not supported, meaning you can only generate the default mb breakpoint ones, or specify breakpoints yourself.

You can open an issue over at GitHub for a feature request. As a workaround you could extend the plugin'S form helper and overwrite FormHelper::_gridClass() to modify the generated classlist, something along the lines of this, which would remove the default breakpoint from the generated class string:

namespace App\View\Helper;

class FormHelper extends \BootstrapUI\View\Helper\FormHelper
{
    protected function _gridClass(string $position, bool $offset = false): string
    {
        return str_replace('-md', '', parent::_gridClass($position, $offset));
    }
}
public function initialize(): void
{
    parent::initialize();

    $this->initializeUI();

    $this->helpers['Form'] = [
        'className' => \App\View\Helper\FormHelper::class
    ];
}

See also https://book.cakephp.org/4/en/views/helpers.html#creating-helpers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文