Using multiple form field widgets for the same fie

2019-09-09 22:00发布

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?

2条回答
家丑人穷心不美
2楼-- · 2019-09-09 22:47

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.

查看更多
地球回转人心会变
3楼-- · 2019-09-09 22:49

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.

查看更多
登录 后发表回答