Notifications
Clear all

[Closed] Radio Button pre-select value  

Page 1 / 2

engagingemotions
Posts: 7
(@engagingemotions)
Active Member
Joined: 4 months ago

I'm trying to add a simple Yes No radio button.  There's a reason why this HAS to be a radio button.  I would like the default value to be Yes.  Is there a way to do this as in HTML?

13 Replies
Elvina
Posts: 680
Moderator
(@elvina)
Honorable Member
Joined: 7 months ago

Hi @engagingemotions

The developers know about your question and currently trying to find some solution for you. I'll update the topic once I get some response from them.

Also please don't duplicate questions and topics in both forums. All questions related to the wpForo Paid Addons should be asked here.

Tom
Posts: 3113
 Tom
Admin
(@tomson)
Support Team
Joined: 5 years ago

Hi @engagingemotions,

We've added a feature to set default value for checkbox, radio and select fields. It contains changes in the core wpForo plugins so it'll be available with next version release.

However, you can add it in your wpForo installation now. You should change one file in the plugin. Use some FTP Client or Hosting Service cPanel > File manager and change the class-forms.php file.

1. Download this zip file ( class-forms.php.zip ).

2. Unzip and find the class-forms.php file.

3. Upload and replace your current /wp-content/plugins/wpforo/wpf-includes/class-forms.php file.

4. Once the file is uploaded, you can set default value by inserting brackets "[" and "]" in the beginning and in the end of the default option in Field Editing screen. Also, make sure the Radio Button option is set required:

  • [Yes]
  • No
wpForo Users Custom Field Addon set default value

In case you use value => label syntax, you should put brackets around the whole row:

  • [1 => Yes]
  • 0 => No

 

engagingemotions
Posts: 7
(@engagingemotions)
Active Member
Joined: 4 months ago

Tom. Firstly many thanks for this now excellent response.  I've installed the new file and can say that the preselection works well.

However there does seem to be an issue.  The Yes/No field is presented in the 'Account' Form correctly with the "Yes" preselected.  Good so far.

However if one then clicks on 'Profile' form, the Yes/No field has not appeared .... presumably the Profile Form is not recognising that the Yes/No field has been populated and therefore does not display it.  This kind of defeats the object of the exercise as other members viewing profile are not going to see the preselected value.

Is there anything you can do on this please?  Or is there something else that I need to do?  Confident to tweak php at this end if you can suggest anything.

engagingemotions
Posts: 7
(@engagingemotions)
Active Member
Joined: 4 months ago

PS .... If I use the form you suggest

[1=>Yes]

0=>No

Then when the Account Form is saved, this field in the Profile Form is display as "1" , not Yes. 

2 Replies
Elvina
Moderator
(@elvina)
Joined: 7 months ago

Honorable Member
Posts: 680
Posted by: @engagingemotions

However if one then clicks on 'Profile' form, the Yes/No field has not appeared

The Yes/No will be displayed once user saved own profile data. Also, you should add this field in Profile page in Dashboard > Forums > Member Fields > Profile Page Tab.

We also suggest that you add all required fields in the registration form.

Tom
 Tom
Admin
(@tomson)
Joined: 5 years ago

Support Team
Posts: 3113

@engagingemotions

Yes, it's correct. We recommend use just "Yes" without "1".

Page 1 / 2
Share: