[development] wit's end: altering options for an optionwidgets_select element - OR - life without #DANGEROUS_SKIP_CHECK
Harry Slaughter
harry at devbee.com
Mon Mar 9 21:12:32 UTC 2009
I want to alter the options for a cck optionwidgets_select element based on data
in the node itself.
I can't use a function in the cck widget configuration page because that's
called before the node is loaded, so I don't know what the options should be yet.
I can't do it in hook_form_alter() because optionwidgets_select elements have
not yet been fully rendered (the actual options for the select have not been set
yet).
I can make the alteration using #pre_render, but then form validation has run
already so I've corrupted the form and I fail _form_validate() and get the
'illegal choice...' error. And I cannot use the
drupal_process_form()/drupal_rebuild_form() trick (as seen in AHAH) because the
#pre_render callback does not have access to $form_state.
I can't use #DANGEROUS_SKIP_CHECK because it has been removed.
Maybe I could use AHAH, but that would be very hacky as I do not need any input
from the user in order to generate my options, just data from the node itself.
The upgrade doc says to look here for alternatives to #DANGEROUS_SKIP_CHECK:
http://drupal.org/node/182310 - yet that issue supplies no examples of a workaround.
I understand the reason for removal of #DANGEROUS_SKIP_CHECK, but this use case
is the type that the option was truly created for (I think :)
I'm posting this question to the list after several days of trying every
solution I could think of.
If there is a solution, surely it will help others as well.
--
Harry Slaughter
Web Developer
Devbee - Effective Drupal
http://devbee.com/
619-249-8780
More information about the development
mailing list