问题
I would like to be able to use multiple form field widgets for the same field and to be able to switch it based on session data from the user. But I am not really sure how to accomplish this. This is for Drupal 6. Any ideas on how to accomplish this?
回答1:
You might be able to accomplish this with one of the field access modules but to do it properly you'd probably need to create a custom widget. Your widgets can return existing widgets by calling their handles, so your widget would more or less be a wrapper that returns the correct widget call.
this tutorial gives a pretty good overview of widget creation in Drupal 6.
回答2:
What I ended up doing was creating a second form field that uses the filefield upload widget and loaded it on the form alongside the Flash widget. Then I put JS on the page that detects if Flash is on the page and is of the correct version. If it is found then it hides the html/AJAX uploader. If it is not then it hides the Flash uploader.
来源:https://stackoverflow.com/questions/9466895/using-multiple-form-field-widgets-for-the-same-field-in-drupal