Giter VIP home page Giter VIP logo

Comments (9)

ADmad avatar ADmad commented on May 28, 2024 2

no need to repeat and set always the template confirmJs before calling postLink in templates

Having to set ['confirmJs' => 'foo'] instead of already possible ['templates' => ['confirmJs' => 'foo'] isn't much of an improvement. String templates were introduced to avoid bloating helper functions with custom options.

from bootstrap-ui.

ADmad avatar ADmad commented on May 28, 2024 1

Or you can just load a templates file to override the default templates and avoid having to do so for each call.

from bootstrap-ui.

gludie avatar gludie commented on May 28, 2024

Add-on and similar for the html link helper (2 examples)

use BootstrapUI\View\Helper\HtmlHelper as BootstrapHtmlHelper;

class HtmlHelper extends BootstrapHtmlHelper
{
    public function linkModal($title, $url = null, array $options = []): string
    {
        // suppress the standard core confirm script
        $this->setTemplates(['confirmJs' => 'return false;']);
        
        return parent::link($title, $url, $options);
    }

    public function link($title, $url = null, array $options = []): string
    {
        if (isset($options['confirmJs'])) {
            $confirmJs = $options['confirmJs'];
            unset($options['confirmJs']);
            $this->setTemplates(['confirmJs' => $confirmJs]);
        }

        return parent::link($title, $url, $options);
    }

}

Usage:

<?= $this->Html->linkModal(
        __('Confirm link'),
        ['action' => 'index', uniqid('link')],
        [
            'confirm' => 'Do you want to go to this page ?',
            'class' => 'nav-link',
            'data-bs-toggle' => "modal",
            'data-bs-target' => "#bootstrapModal",
        ]
    ) ?>

from bootstrap-ui.

dereuromark avatar dereuromark commented on May 28, 2024

It would be easier to directly make PRs here

from bootstrap-ui.

gludie avatar gludie commented on May 28, 2024

from bootstrap-ui.

dereuromark avatar dereuromark commented on May 28, 2024

You can keep it open for now, no worries.
Maybe others would like to also give some early feedback.

from bootstrap-ui.

gludie avatar gludie commented on May 28, 2024

agree, I am pretty sure to have checked this as well admad … problem I had was the missing handling of variables in templates, but will recheck if templates is supported for Forms postLink(…) …

from bootstrap-ui.

gludie avatar gludie commented on May 28, 2024

as far as I can see now, templates is only supported for controls. Html and Form Helper do use core implementation for link and postLink. here the journey started. may be there is a smarter way than I did currently and use templates option of 'link' and postLink like it was introduced for controls. Let's see. Another possibility which came into my mind was to redefine core function _confirm.

from bootstrap-ui.

ADmad avatar ADmad commented on May 28, 2024

Please open an issue for the core to allow using templates options for the link methods.

from bootstrap-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.