I tested this field adn set as required but when I select 'Other' and DO NOT type anything the node is saved without informing that field is required.
Is that a bug or you want to make it working like that ?

Thanks for quick module, its good that is saves the other value in the same field.

Do you still mantain that ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mradcliffe’s picture

Component: Miscellaneous » Code
Assigned: Unassigned » mradcliffe

I'll take a look into this as soon as I can.

benone’s picture

Component: Code » Miscellaneous
Assigned: mradcliffe » Unassigned

Wow :) if you take a look as fast as you answered it will be a drupal issue record in patching time ;)

benone’s picture

I tested again when I do not type anything it just fill this field with word 'other'. I can see that when I go to edit.

mradcliffe’s picture

Assigned: Unassigned » mradcliffe
Status: Active » Needs review
FileSize
1.06 KB

This patch passes all tests currently. I may write a test specifically for this case.

mradcliffe’s picture

FileSize
2.75 KB

Okay, here's a patch with an added test to test default values. Passes.

I ran the test with the .module file unpatched, and it failed. So that's good too.

benone’s picture

Thats great.

In meanwhile I found also this module and gave it a try - http://drupal.org/project/select_or_other .

It works in exactly the same way. Can you explain me the difference between them ?

I checked using devel if the other field value is stored in the same field and it is.

So I actually dont see any difference. Is there any ?

mradcliffe’s picture

There really isn't much difference. I didn't find the module until after I had developed this one and posted it, but need to keep this one updated.

benone’s picture

orayt, understand.

mradcliffe’s picture

Status: Needs review » Closed (fixed)
mradcliffe’s picture

Status: Closed (fixed) » Active

oops

mradcliffe’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

The patch is working in Drupal 6. There is the same problem in Drupal 7, but it needs additional finagling to get it to work. It seems that default values are not same the same way as they are in CCK in Drupal 6 (ugh, D7 field api).

mradcliffe’s picture

Status: Active » Needs work

setting status.

mradcliffe’s picture

Component: Miscellaneous » User interface
Status: Needs work » Needs review
FileSize
2.37 KB

For D7 (and maybe changing for D6): A better way to do this is with required option on fields and do an option element_validate callback if required is set.

Hindsight is 20/20

mradcliffe’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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