Can I provide default choice option for poll? which mean I want fix options 'Yes' and 'No' for choice for every poll created by users.
I want to make these fields type hidden with the choice 'Yes' and 'No'.

Comments

anders.fajerson’s picture

Version: 5.x-1.0-beta5 » 5.x-1.x-dev
Assigned: web2 » anders.fajerson
Category: support » feature

No, but this would be a nice addition on the content type settings page (I've actually thought of that recently). Some of the code at http://drupal.org/node/145863#comment-317127 could probably be re-used since a textarea with one choice per row makes sense here. I guess we could also provide a setting to "hide" this default choices on the edit page.

The other option is to use hook_form_alter() to programatically interact with the form on the edit page.

anders.fajerson’s picture

Title: Provide default choice option » Provide default choices
Priority: Normal » Critical

I'd like to get this in before 1.0. I see what I can do.

anders.fajerson’s picture

Status: Active » Needs review
StatusFileSize
new1.99 KB

Some duplicate code in advpoll_form, but I couldn't come up with a better way to write this. I'll take care of "uninstalling" the new variable in the issue dealing with that.

ChrisKennedy’s picture

Status: Needs review » Reviewed & tested by the community

Nice, I like the simple way of implementing this.

One nitpick: for the first variable_get, make the default value NULL, then check !isset() [or !== NULL] rather than !empty() so that 0 can be the only default choice (might as well allow it).

Otherwise, RTBC.

nancydru’s picture

I like to set all my defaults in hook_enable. Then it's easy to reset them: disable and re-enable it.

anders.fajerson’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.98 KB

Changed to $default_choices != '' and kept default value as ''. The default value will only be set if the user never saved the content type settings page, else it's saved as '' to the variable table.

ChrisKennedy’s picture

Status: Needs review » Reviewed & tested by the community

Sounds good to me.

anders.fajerson’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.