Comments

johnpitcairn’s picture

Ack. And here I was hoping I could use this to allow users to select topics for an article and drag-rearrange those to indicate the relative importance of each topic. That's a pretty good use-case IMO.

@mikeker, are you working on this? It's assigned to you...

Niremizov’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Assigned: mikeker » Niremizov
Status: Active » Needs review
StatusFileSize
new1.46 KB

If someone still needs functionality of saving (working) with multiple values by using this module, here is a small patch that fixes module's work. Rearranging items works too.

BTW: I was testing it with unlimited cardinality.

mikeker’s picture

My apologies, this one fell off my radar. I'll review the patch in #2 in the next few days -- if I don't, please raise hell in this issue! :)

Again, sorry for the delays!

Niremizov’s picture

I have changed a bit previous patch, so it won't conflict with other modules (like content taxonomy, if support will be added #1548858)

arhak’s picture

@#4
I'm not up to date with D7 fields API
but I guess it can't be that far from D6 CCK..

//Check if $value is empty make it a string

- there should be an API function to test wether a field is empty, since the definition of "empty" varies depending on the type of field and widget
- there should be as well, an API function to set the field to "empty" (without pushing a FALSE, rather letting module hooks react)
- ..otherwise, you'll find yourself inserting custom code for each crazy third party module

- also, the comment states "make it a string", but the code doesn't do that, those should be in correspondence

my two cents

Niremizov’s picture

Okey, after digging a bit it turned out, that we don't need check for field is empty or not... Because we are actually doing it before: line 88 (after using patch) taxonomy_single_tag.module

if ($tag = $element['#value']) {
...
}

And default empty value is set before that if statement... So made some changes to patch in #2.

arhak’s picture

@#6 and I guess that testing if($tag) is safe in this case, because we are dealing with taxonomy (core's terms)
and no other kind of fields

nevertheless, a well documented comment would improve readability
(why not using empty)

Niremizov’s picture

Well the same check is made inside taxonomy.module itself... so i just commented to @see taxonomy_field_is_empty()... Isn't it enough?

And actually we still can use empty function, for check input values like $element['#value']:

if (empty($element['#value'])){
...
}

In our case this statement is safe too... So i'am confused a bit, about commenting...

SidneyGijzen’s picture

I applied patch from #6 successfully to the current 7.x-1.1 version. Thanks Niremizov!

opstao’s picture

Patch from #6 is working for me. I don't understand why, but without the patch, I was getting errors not only with the new field where the "Single tag autocomplete text field" widget was applied, but also with other fields allowing multiple-item adding – even though they were neither autocomplete nor based on taxonomy terms.

drclaw’s picture

I also had some success with the patch from #6, however there were still some undefined index errors if ajax requests were made on the page with a single taxonomy tag field. An image field for example. Attached patch adds an extra check to make sure there's a weight value on the form input before. Additionally I removed a some commented out debugging statements and cleaned up a bit to match drupal's coding standards.

arhak’s picture

Assigned: Niremizov » mikeker

hand it over to the maintainer of this branch

mmm... its been a while since mikeker@#3 ...

mikeker’s picture

Status: Needs review » Fixed

Apologies for the wait... I've committed #11 to the 7.x branch.

Thank you for your work on this issue!

arhak’s picture

thanks mike

arhak’s picture

thanks mike

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.