Using multiple form field widgets for the same field in Drupal

自作多情 提交于 2019-12-25 04:18:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!