Yes, you should have a form template called autocomplete which your widget
is using.

See
http://book.cakephp.org/3.0/en/core-libraries/helpers/form.html#customizing-the-templates-formhelper-uses
and
http://www.sanisoft.com/blog/2014/08/11/twitter-bootstrap-forms-cakephp-3/
Specifically Step 2

HTH

T

On Wed, Oct 1, 2014 at 10:01 AM, Radharadhya Dasa <[email protected]> wrote:

>
> > Show us the from template for autocomplete
>
> I do not have anything else. Should I?
>
> Rrd
>
> >
> > T
> >
> > On Tue, Sep 30, 2014 at 7:59 PM, Radharadhya Dasa <[email protected]> wrote:
> >>
> >> 1. /src/View/Widget/Autocomplete.php
> >>
> >> <?php
> >> namespace App\View\Widget;
> >>
> >> use Cake\View\Widget\WidgetInterface;
> >> use Cake\View\Form\ContextInterface;
> >>
> >> class Autocomplete implements WidgetInterface {
> >>
> >>     protected $_templates;
> >>
> >>     public function __construct($templates) {
> >>         $this->_templates = $templates;
> >>     }
> >>
> >>     public function render(array $data, ContextInterface $context) {
> >>         $data += [
> >>             'name' => '',
> >>         ];
> >>         return $this->_templates->format('autocomplete', [
> >>             'name' => $data['name'],
> >>             'attrs' => $this->_templates->formatAttributes($data,
> ['name'])
> >>         ]);
> >>     }
> >>
> >>     public function secureFields(array $data){
> >>        return [];
> >>     }
> >> }
> >> ?>
> >>
> >> 2. /src/Controller/AppController.php
> >>
> >> <?php
> >> namespace App\Controller;
> >>
> >> use Cake\Controller\Controller;
> >> use Cake\Event\Event;
> >>
> >> class AppController extends Controller {
> >>
> >>     public $components = [
> >>         'Flash',
> >>         'Auth' => [
> >>             'loginRedirect' => [
> >>                 'controller' => 'users',
> >>                 'action' => 'view'
> >>             ],
> >>             'logoutRedirect' => [
> >>                 'controller' => 'Pages',
> >>                 'action' => 'display',
> >>                 'home'
> >>             ]
> >>         ]
> >>     ];
> >>
> >>     public $helpers = [
> >>         'Form' => [
> >>             'widgets' => [
> >>                 'autocomplete' => [
> >>                     'App\View\Widget\Autocomplete',
> >>                     'text',
> >>                     'label'
> >>                 ]
> >>             ]
> >>         ]
> >>     ];
> >>
> >>     public function beforeFilter(Event $event) {
> >>         $this->Auth->deny();
> >>     }
> >> }
> >>
> >>
> >>
> >> 3. /src/Template/Contacts/add.ctp
> >>
> >> <div class="actions columns large-2 medium-3">
> >>     <h3><?= __('Actions') ?></h3>
> >>     <ul class="side-nav">
> >>         <li><?= $this->Html->link(__('List Contacts'), ['action' =>
> 'index']) ?></li>
> >>     </ul>
> >> </div>
> >> <div class="contacts form large-10 medium-9 columns">
> >> <?= $this->Form->create($contact) ?>
> >>     <fieldset>
> >>         <legend><?= __('Add Contact'); ?></legend>
> >>     <?php
> >>         echo $this->Form->autocomplete('name');
> >>     ?>
> >>     </fieldset>
> >> <?= $this->Form->button(__('Submit')) ?>
> >> <?= $this->Form->end() ?>
> >> </div>
> >>
> >>
> >>
> >> Result: In the generated html there is no input for name at all.
> >>
> >> rrd
> >>
> >>
> >> 2014. szeptember 30., kedd 14:33:24 UTC+2 időpontban Radharadhya Dasa a
> következőt írta:
> >>>
> >>> Hi,
> >>>
> >>> I am trying to make an autocomplete input work on Cake 3.0
> >>>
> >>> The current 3.0 cookbook gives a code example here :
> http://book.cakephp.org/3.0/en/core-libraries/helpers/form.html
> >>>
> >>> If I try it I get an error message:
> >>> Fatal error: Declaration of App\View\Widget\Autocomplete::render()
> must be compatible with Cake\View\Widget\WidgetInterface::render(array
> $data, Cake\View\Form\ContextInterface $context) in
> /home/rrd/public_html/sanga/src/View/Widget/Autocomplete.php on line 6
> >>>
> >>> If I change my render function to
> >>> public function render(array $data, Cake\View\Form\ContextInterface
> $context) {
> >>>
> >>> Still I get the same error message.
> >>>
> >>> Any idea how to solve this?
> >>>
> >>> rrd
> >>
> >> --
> >> Like Us on FaceBook https://www.facebook.com/CakePHP
> >> Find us on Twitter http://twitter.com/CakePHP
> >>
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups "CakePHP" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> >> To post to this group, send email to [email protected].
> >> Visit this group at http://groups.google.com/group/cake-php.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> >
> > --
> > =============================================================
> > Hire a CakePHP dev team : http://sanisoft.com
> > =============================================================
> >
> > --
> > Like Us on FaceBook https://www.facebook.com/CakePHP
> > Find us on Twitter http://twitter.com/CakePHP
> >
> > ---
> > You received this message because you are subscribed to the Google
> Groups "CakePHP" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/cake-php.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
=============================================================
Hire a CakePHP dev team : http://sanisoft.com
=============================================================

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to