0

Need some help again! I have seen many tutorials but they couldn`t help me.Then I decided to ask.

I`m using cakephp 2.5.5

I have this relationship:

Vendor has_many EventVendor

EventVendor belongs_to Vendor

in View\EventVendors\edit.ctp I have this form:

<?php
    echo $this->Form->input('id');
    echo $this->Form->input('vendor_id');
    echo $this->Form->input('description');
    echo $this->Form->input('quantity');
    ... more code
?>

This line:

echo $this->Form->input('vendor_id'); 

Is a selectbox that cakephp creates, but I need it to be an input(type text) where user will be able to type the vendor`s name and jquery autocomplete will complete automatically(autocomplete is working fine in other inputs).

The problem is: vendor_id is a foreign_key, because that I need to store the vendor's 'Id' instead of the vendors 'name'.

How can I do that?

1 Answers1

2

I think you need someting like select2. Your field vendor_id should still be a list (like cake automatically baked). If you put select2 on it (see the examples) the user is able to type its choice.

Bob
  • 873
  • 1
  • 8
  • 21