autocompleting one field, but applying another

A place for users and developers of the Xataface to discuss and receive support.

autocompleting one field, but applying another

Postby cmatos72 » Sat Feb 11, 2012 10:08 pm

Im not sure how to describe exactly what i am running into, but it is likely a rookie db development mistake.
I got a number of tables. The relationship between two of the tables is one to many: accounts and address.
i got an Account_ID which is auto_incremented and the primary key in the account table. Then i have the same account key in the address table as a foreign key. When i add a new record on the address tab of xataface, the address_id field is looking for a integer, so i cant add the BusinessName autocomplete from the accounts table, since it isnt an integer. I havent been able to find a way around this. Any help is appreciated.

account_t
PK Account_ID
BusinessName

address_t
PK Address_ID
FK Account_ID
address
contact name
etc.

in address_t directory i currently have an valuelists.ini with the following statement:
[Accounts]
__sql__ = "SELECT Account_ID, BusinessName FROM account_t ORDER BY BusinessName"

and a fields.ini with the following:
[Account_ID]
widget:type = autocomplete
vocabulary = Accounts

what i like is, when someone enters in a new address, to be able to pick a company from the list, if there is an existing company, else add one.

thanks ahead for your time.
Carlo.
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm

Re: autocompleting one field, but applying another

Postby shannah » Sun Feb 12, 2012 11:06 am

I don't think the autocomplete widget will work with valuelists where the keys aren't the same as the values. (I know this sucks). I developed the yui_autocomplete widget to overcome this shortcoming. I.e. If you change widget:type=autocomplete to widget:type=yui_autocomplete I believe it will work.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: autocompleting one field, but applying another

Postby cmatos72 » Sun Feb 12, 2012 12:23 pm

Thanks for the quick reply Steve,
I changed it to yui_autocomplete, and it still doesnt work.
When i change the widget type to select it does work.
I am starting to believe that the browser autocomplete is the problem.
All the fields seem to have an autocomplete drop down list.
Have you run into this before. I liked it before, but now that it seems the choices arent query results,i may have to use the select option.......problem is there will be many clients in the database, which means the select options wont be a good one.
Have any ideas?
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm

Re: autocompleting one field, but applying another

Postby cmatos72 » Sun Feb 12, 2012 12:30 pm

Hey Steve,
Played around some more with the select widget type. Its exactly they way i want it to work.
In other words, select company from existing list, or if not there add new company.
yui_autocomplete saves the value 0 every time. the Account_ID has an integer value.
I believe since the company name has characters, it defaults to "0"?
Am i doing something wrong?
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm

Re: autocompleting one field, but applying another

Postby shannah » Sun Feb 12, 2012 6:31 pm

Come to think of it, you're right... I think the yui_autocomplete may have had this same limitation.
The select widget should give users the option of adding an option if they have edit permissions on the table from which the vocabulary comes.

I have a few modules developed for Xataface 2.0 (not released yet) that will improve the offering for widget (e.g. there is a tagger widget that will work this way -- http://xataface.com/dox/modules/tagger/latest).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: autocompleting one field, but applying another

Postby cmatos72 » Sun Feb 12, 2012 7:18 pm

That's too bad about the yui_autocomplete limitation.
For now (until version 2 comes out) I'll stick with the select widget.
The tagger widget and general look of version 2.0 is looking great!
And if i haven't done so yet, thanks for developing such a wonderful tool.
I have some other questions, and found some suggestions from prior posts.
I'm going to try those suggestions to see if i can get it to work.
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm

Re: autocompleting one field, but applying another

Postby cmatos72 » Mon Feb 13, 2012 11:11 am

Hey Steve,
the depselect module says it needs v 1.4 which i dont see available.
did 1.4 turn into 2.0? If so, is it close to release?
if not i'll add the javascript solution.
thanks.
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm

Re: autocompleting one field, but applying another

Postby cmatos72 » Mon Feb 13, 2012 12:36 pm

Im trying figure out how everything fits together.
I tried following the directions on this page:
http://xataface.com/wiki/Dynamic_select_boxes
but i cant seem to get it to work.

I created valuelists.ini, fields.ini, and dynamic_update.php in the tables directory i want this dynamic update of fields.
i changed all the "field" names to my db field names. left all the variables as is.
My question is:
where do i place the last part of the delegates section?
// Also place this javascript after an edit record form...
function block__after_edit_record_form(){
return $this->block__after_new_record_form();
}
cmatos72
 
Posts: 6
Joined: Sat Feb 11, 2012 9:53 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 12 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved