Giter VIP home page Giter VIP logo

Comments (4)

ndm2 avatar ndm2 commented on June 7, 2024 1

The first error means that you have not (or incorrectly) added a template to the form helper, if you look in the linked book section, its done there using:

$this->Form->setTemplates([
    'autocomplete' => '<input type="autocomplete" name="{{name}}" {{attrs}} />'
]);

The second error means that you possibly did something like $this->Form->autocomplete() without an argument for the field name.

from bootstrap-ui.

ndm2 avatar ndm2 commented on June 7, 2024

Where exactly are you using $this->Form->addWidget()? It should work fine in templates, but it could break the form helper loading "order" when used in a view class.

from bootstrap-ui.

umer936 avatar umer936 commented on June 7, 2024

The first message in this thread was from the View class. I figured that was the case that it would break the Form helper.
However, there are issues trying to use it in templates as well.

in templates/Pages/home.php, putting

$this->Form->addWidget(
    'autocomplete',
    ['Autocomplete', 'text', 'label']
);

results in
Cannot find template named 'autocomplete'.

Whereas putting

$autocomplete = new AutocompleteWidget(
    $this->Form->getTemplater(),
    $this->Form->getWidgetLocator()->get('text'),
    $this->Form->getWidgetLocator()->get('label'),
);
$this->Form->addWidget('autocomplete', $autocomplete);

results in
Missing field name for FormHelper::getTemplater

I was thinking this was related to bootstrap-ui overwriting the templates. I have not tried this in a fresh project without the plugin

from bootstrap-ui.

umer936 avatar umer936 commented on June 7, 2024

Oh wow. I did not understand the docs correctly.

This widget would render the “autocomplete” string template, such as:

$this->Form->setTemplates([
    'autocomplete' => '<input type="autocomplete" name="{{name}}" {{attrs}} />'
]);

Made me think that simply doing the addWidget() would make CakePHP run the setTemplates()—not that I had to do it.

Works as intended.
Evidently not an issue with bootstrap-ui.

Thank you for your help. Closing.

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.