Just going off the screen shot I would request that displaying the other text field happens only after selecting "Other" in the drop down list

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Flying Drupalist’s picture

subscribe

mradcliffe’s picture

Yes. Actually at the our local user meeting today it came up. Someone was supposed to submit the new feature request, but I guess you beat him to it. ;-)

bryancasler’s picture

I felt awkward jumping in with a suggestion this early but this is a feature I've long wanted and was overly excited to see you guys working on it. Can't wait to give it a go.

mradcliffe’s picture

Status: Active » Needs work
FileSize
6.03 KB

CCK and #ahah is fairly tricky to get right. I have something somewhat working, but it has issues. I might not have time to work on it for a while so I'll throw the patch up here.

issues:

  • validation error is killing the form again.
  • extra fieldset being added once. Probably an issue with how i'm doing the replace (wrapper).
  • field groups may not be taking accounted for in the ahah callback.
3dloco’s picture

Issue tags: +conditional fields, +cck other

+1 ;-D

eme’s picture

Indeed, it would be awsome! Why take AHAH and not just a javascript?

Other question : is it necessary then to have the field into a fieldset?

Anyway it's a really great idea!

Flying Drupalist’s picture

You need to use AHAH when making forms because of some security stuff drupal has going on to prevent injections. I think.

But in this case I don't think AHAH is necessary. Load the textfield on page load, then hide it with js. When other is selected show it again, and it'll work fine.

eme’s picture

Exactly. Like the Conditionnal field module which does exactly that to hide CCK fields.

mradcliffe’s picture

FileSize
2.85 KB

Thank you for the feedback. I've been working on this a bit more, and I think you're right about not using AHAH/AJAX. Again, still a work-in-progress. I'll probably put this on hold until I get testing finished up.

mradcliffe’s picture

Assigned: Unassigned » mradcliffe
Status: Needs work » Needs review
Issue tags: -conditional fields +JavaScript
FileSize
3.59 KB

Okay, after some changes to the dev version to fix some things up after I added testing... I have a patch ready to test for this.

Please use the latest dev version when it updates within 12 hours of this post.

clashar’s picture

I am getting error in the header of my page:
//$Id$ /** * cck_select_other javascript file */ var cckSelectOther = {}; Drupal.behaviors.cckSelectOther = function (context) { // $.browser.msie == true ? $(this).click(Drupal.ConditionalFields.fieldChange) : $(this).change(Drupal.ConditionalFields.fieldChange); $.browser.msie == true ? $(this).click(cckSelectOther.blah) : $(this).change(cckSelectOther.blah); var selectId = 'edit-field-'+Drupal.settings.CCKSelectOther.field+'-select-other-list'; var inputId = 'edit-field-'+Drupal.settings.CCKSelectOther.field+'-select-other-text-input-wrapper'; var value = $('#'+selectId+' option:selected').val(); if (value == "other") { document.getElementById(inputId).style.display = 'block'; } else { document.getElementById(inputId).style.display = 'none'; } } cckSelectOther.blah = function () { var selectId = 'edit-field-'+Drupal.settings.CCKSelectOther.field+'-select-other-list'; var inputId = 'edit-field-'+Drupal.settings.CCKSelectOther.field+'-select-other-text-input-wrapper'; var value = $('#'+selectId+' option:selected').val(); if (value == "other") { document.getElementById(inputId).style.display = 'block'; } else { document.getElementById(inputId).style.display = 'none'; } }

currently I receive this error wether I try to install or uninstall the module.

Maybe I made a mistake, because firstly I copied patched file directly to server without uninstalling module. So now I can't use nor old version nor new one. I tried to uninstall or install, but always I do receive above mentioned error.

So now I can't achieve that module is to be displayed in "Uninstall" tab of Modules. Should it be?

clashar’s picture

please say what table/fields should be deleted to make a clean module delete?

mradcliffe’s picture

Hmm, that's odd. I've been patching it and reversing the patch multiple times on both mysql and postgresql boxes.

The module doesn't need to be uninstalled. You can remove a module from the system table by running delete from system where name = 'cck_select_other'; or you can disable it by changing status to 0. You also can reverse a patch by running patch -p0 < cck_select_other-js.patch and it will ask if you want to reverse it.

clashar’s picture

mradcliffe, thank you for quick reply.
Actually I didn't apply patch on server because I have no such access, instead I have applied patch on my local machine and just uploaded it with replacement to server. I have also tried to delete data from system table, but still with no success to delete the error.

But I found another similar module "Select (or other)": http://drupal.org/project/select_or_other.

If there is a big difference b/w these modules?

eme’s picture

The last dev release does not include the js.. Is it normal?

I just tested the module above : it is indeed the same objective, the module being maybe more complex, but the thing is that is did not work on my install...

mradcliffe’s picture

Yes. This functionality has not been committed. It is in the latest attached patch.

(other module) I'm really depressed now because I thought I searched endlessly for it.

mradcliffe’s picture

Status: Needs review » Fixed

committed.

Status: Fixed » Closed (fixed)
Issue tags: -JavaScript, -cck other

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