autocomplete and "tag"/"tags"

144 views
Skip to first unread message

Rosemary Le Faive

unread,
Apr 22, 2013, 5:14:18 PM4/22/13
to isla...@googlegroups.com
Hi,

I've been making forms with the islandora_xml_forms module (7.x), and I noticed that the "tag"-type form element (i.e. the text field where you can add additional text fields; often used for subjects etc.) doesn't work with autocomplete. 

This seems rather silly. Subjects are the types of fields that especially should be autocompleted. Yet it appears to me that the form builder isn't passing these elements through drupal_get_form as "textfield"s, and instead creates these form elements directly into html, so the autocomplete path you may configure in the form builder never enters the picture.

Does anyone have a workaround for this? 

Thanks,

-Rosie

Nigel Banks

unread,
Apr 23, 2013, 3:55:55 AM4/23/13
to isla...@googlegroups.com
Hi,

That would be a nice feature to have. The tags are a custom element type so they are not textfields even though the when they are rendered to html they contain one. I'm unsure of how difficult this task would be, though I would guess one just need to take the autocomplete logic from inside of Drupal theme_textfield function here:


And incorporate it in the Tags and Tag logic below:


I've added a ticket to Jira for this issue:

That being said it may take some time before anyone has free time to add this feature.

Nigel

Rosemary Le Faive

unread,
Apr 23, 2013, 8:16:27 AM4/23/13
to isla...@googlegroups.com
Wow. Thank you! I'll take a stab at it, since you just saved us the hard work of figuring it out.

Rosemary Le Faive

unread,
Apr 23, 2013, 5:59:08 PM4/23/13
to isla...@googlegroups.com
Thanks Nigel! I seem to have it working.

The changes that let Tag fields autocomplete are the last two commits on April 23: 

You may not want to pull straight from my repo, because I've incorporated Alan's pull request and due to my inexperience with git, the rosiel tree is now really wonky. But the code's really simple, so please test it out!

Rosie

Nigel Banks

unread,
Apr 24, 2013, 2:42:52 AM4/24/13
to isla...@googlegroups.com

Hi Rosemary! Thanks! It's great to see this fixed!

I have a work flow for git that you may find useful in keeping the code manageable.

Work flow:

I make sure my 6.x/7.x/master branch always tracks the main islandora/discoverygarden repository, they may be a few commits behind (someone committed code in the interim) but it's never different. I never have commits in my 6.x/7.x/master branches that are not already present in the islandora/discoverygarden repository. This avoids merge problems and keeps me from committing code that I didn't want to commit.

When I want to create a new feature or fix a bug, I create a topic branch like so:

First I checkout my master branch.

git checkout 7.x

Then I update it so I know I'm running the latest code that is available in the public islandora/discoverygarden repository.

git update

The git update is a custom alias I've created which you can get below at the gist link. It basically grabs the latest for the current branch from the remote upstream then pushes those changes into my the remote origin. In this way my upstream remote is always the public canonical islandora/discoverygarden repository, and my remote origin is my personal repository on Github.

It expands into this:

git pull upstream 7.x && git push origin 7.x

So now that my master branch has the latest code, I create my topic branch.

git checkout -b 7.x-fixes-some-bug

Now I do whatever work is required.

If some other issue pop's up, I create another topic branch to deal with it separately, and again first I switch to my master branch.

git checkout 7.x

git update

git checkout -b 7.x-fixes-some-different-bug

I can do this with any number of topic branches, and send pull requests for each of them individually, or after working on several separate topic branches I may want to make them into a single branch. This can be done with rebases/merges.

git checkout 7.x-fixes-some-bug

git merge 7.x-fixes-some-different-bug or git rebase 7.x-fixes-some-different-bug

When I'm ready with my changes I push my topic branch to my personal remote, then issue a pull request.

git push -u origin 7.x-fixes-some-bug

Issue pull request.

Free Book on using Git:

I highly recommend reading the free Pro Git book found here: http://git-scm.com/book

Understanding how to a few of the basic features of git is well worth the investment, it's saved me countless hours of time.

My Custom Git Aliases:

Also checkout some of my git aliases to save you some time!

https://gist.github.com/nigelgbanks/5116805

Creating the pull request for this issue:

There is a lot of git features that aren't covered in the book above and I think cherry-pick is one of them so I've included my work flow below for getting your changes into a pull request.

Here's a walk though of what I did to cherry pick your commits into a separate pull request.

git remote add rosiel git://github.com/rosiel/islandora_xml_forms.git

git fetch rosier

I need to find out the commit hashes so I took a look at your history:

git log rosiel/7.x

commit 120075920a631339719728dd793dfb686e795ca5

Author: Rosemary Le Faive

Date:   Tue Apr 23 17:37:02 2013 -0400

    Insert missing ['#autocomplete_path'] element


commit d6e0b46564f541e3bcea5ad44099d566fe9bfc50

Author: Rosemary Le Faive

Date:   Tue Apr 23 17:27:15 2013 -0400

    Tag elements autocomplete.

…..

With this information I could then cherry-pick your two commits.

But before doing so I created a topic branch (So my local 7.x will still always track against my islandora 7.x)

git checkout -b 7.x-rosiel-tag-autocomplete


At this point my topic branch is the same as my 7.x branch which is the same as the islandora/7.x branch.

git cherry-pick d6e0b46564f541e3bcea5ad44099d566fe9bfc50

git cherry-pick 120075920a631339719728dd793dfb686e795ca5


Now that my topic branch has your two commits, I now push my whole topic branch to my personal Github repository.

I use my custom alias "remote-branch" which is defined in my configuration gist above.


git remote-branch 

Which is equivelent to:

git push -u origin 7.x-rosiel-tag-autocomplete

Then I go onto Github and trigger issue the pull request.

https://github.com/Islandora/islandora_xml_forms/pull/85


Nigel

Nigel Banks

unread,
Apr 24, 2013, 2:58:23 AM4/24/13
to isla...@googlegroups.com
When I went to test the tags, it appears that they are broken for me when using the attached form, if I attempt to add any values they appear as empty tags below the tag field.

It's also broken on the 7.x branch, so its unrelated to this ticket.


Is anyone else seeing this?

Peter Murray

unread,
Apr 24, 2013, 9:12:44 AM4/24/13
to isla...@googlegroups.com
Great summary, Nigel. That is close to my practice as well. I got word from the Open Repositories 2013 program committee that my talk on a "Dev-Ops" setup for LYRASIS' Islandora installation was accepted, so I'll be going over much the same territory.


Peter
--
Peter Murray
Assistant Director, Technology Services Development
LYRASIS
Peter....@lyrasis.org
+1 678-235-2955
800.999.8558 x2955


Nigel Banks

unread,
Apr 25, 2013, 10:42:08 AM4/25/13
to isla...@googlegroups.com
I've sorted the missing values problems and did a review of your changes, Rosemary. Looks good its now part of core, thanks!!!

Rosemary Le Faive

unread,
Apr 25, 2013, 12:27:52 PM4/25/13
to isla...@googlegroups.com
Thanks, Nigel (and Jordan Dukart)! 

I really appreciate the git workflow. Making changes on separate branches is so simple, and will avoid so many issues!

Cheers,

-Rosemary
Reply all
Reply to author
Forward
0 new messages