开发者

drupal Webform select list empty first value

I need for my select lists to have a default option of an empty value, or "Select" with no value. I don't see any mention of how to do this in the documentation. // $Id: 开发者_Python百科webform.module,v 1.196.2.47 2010/08/16 17:54:19 quicksketch Exp $


You can add the patch webform_select_none_0.patch as mentioned in http://drupal.org/node/563170. Or if you do not have any experience with patches, you can add the following code to the _webform_render_select function in /sites/all/modules/webform/components/select.inc (of course taking into account any disadvantages of manually editing code)

if ($component['extra']['aslist'] && !$component['extra']['multiple'] && ($default_value === '' || !$component['mandatory'])) {
    $element['#empty_value'] = '';
}

This will add the - Select - option to mandatory webform select fields when no option is selected


On the webform controls tab (node/%/edit/components/%), all you need to do is uncheck the "Mandatory" checkbox under "Advanced Settings".


Create a custom module and use form alter to modify the output. Explained here: https://www.drupal.org/node/1331956#comment-5876808


I believe you can achieve this with an empty entry in your option list:

|--Choose one--
val1|Value 1
val2|Value 2
val3|Value 3

etcetera.

However, I can't seem to find any sources on this at the moment. Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜