Notifications
Clear all

Paid Addons Support Forum Only

Please note, that here we only support Paid Addons issues and questions.

gVectors Support staff works from 6am to 6pm (GMT+0)

All questions related to wpForo and wpDiscuz free plugins should be asked in the corresponding plugin support forum:

 

wpDiscuz Support Forum wpForo Support Forum

Problem with html field


Marios Georgiou
Posts: 6
Customer
Topic starter
(@marios-georgiou)
Member
Joined: 1 week ago

Hello, I recently purchased the Topic Custom Fields addon and have some slight problems.

I managed to create my custom html code for my topic.

The first problem is that I

can't seem to get the dropdown to be the same width as the other fields.

The other problem is that when I choose my input, when I add the topic, the value doesn't get saved.

I also attach some screenshots.

Thanks in advance,

Marios

forum question custom html
forum question width
forum question dropdown
10 Replies
Kyle
Posts: 247
 Kyle
Admin
(@kylew)
Member
Joined: 10 months ago

Hi @marios-georgiou,

Please provide your forum URL,

about the dropdown width, how I see the dropdown width is wider because of the "Police Measures directed at Perceptions of Migrants".

Reply
Marios Georgiou
Posts: 6
Customer
Topic starter
(@marios-georgiou)
Member
Joined: 1 week ago

Hello Kyle,

This is my forum URL : https://perceptions.aditess.com/

As far as my width question goes, I would like box 1 to be the same width as box 2, shown in the attached picture.

I have tried with css but that is as wide as it goes.

Thanks in advance,

Marios

Reply
Tom
Posts: 3816
 Tom
Admin
(@tomson)
Support Team
Joined: 7 years ago

@marios-georgiou,

You are doing all incorrect. The HTML field is not for adding form fields, the HTML field is only for HTML codes around the fields. You should never put HTML code of form fields in this field. All fields MUST be created using corresponding options in Add Field screen:

wpForo Topic Custom Fields Add Dropdown Field

Please remove your HTML code and use the correct way to add fields in Topic Form.

Reply
4 Replies
Marios Georgiou
Customer
(@marios-georgiou)
Joined: 1 week ago

Member
Posts: 6

@tomson The problem with that is that the field that I use is not a simple dropdown. I want to have subcategories for each category inside the dropdown. Is there a way I can achieve that?

Reply
Tom
 Tom
Admin
(@tomson)
Joined: 7 years ago

Support Team
Posts: 3816

@marios-georgiou,

I'm sorry, but there is no way to do that. You should use the dropdown field to create it. As an alternative to option groups, you can add the same phrase before each option to imitate groups, something like this:

  • Group 1: Option Name
  • Group 1: Option Name
  • Group 2: Option Name
  • Group 2: Option Name

 

Reply
Marios Georgiou
Customer
(@marios-georgiou)
Joined: 1 week ago

Member
Posts: 6

@tomson Thanks for your time. I did end up implementing it like that. But maybe this is something you can add in a future update?

Reply
Tom
 Tom
Admin
(@tomson)
Joined: 7 years ago

Support Team
Posts: 3816

@marios-georgiou,

Yes, we'll take this under consideration for sure.

Reply
Tom
Posts: 3816
 Tom
Admin
(@tomson)
Support Team
Joined: 7 years ago

 Hi @marios-georgiou,

Could you please try this syntax for dropdown options:

[optgroup=Group 1]
Value 1
Value 2
[/optgroup]
[optgroup=Group 2]
G2 Value 1
G2 Value 2
[/optgroup]
admin – Account – wpForo And Addons Forum — Mozilla Firefox
Member Fields ‹ wpForo And Addons — WordPress — Mozilla Firefox

 

Reply
2 Replies
Marios Georgiou
Customer
(@marios-georgiou)
Joined: 1 week ago

Member
Posts: 6

@tomson Hello Tom,

Thanks for the follow up.

I copied the syntax that was included in the screenshot but unfortunately it didn't work.

optgroup
optgroup result
Reply
Tom
 Tom
Admin
(@tomson)
Joined: 7 years ago

Support Team
Posts: 3816

@marios-georgiou,

I'd recommend the following change in the topic custom fields plugin until we release a new version.

Use some plugin which allows editing plugin files or the built-in WordPress plugin file editor, find and open this file: wp-content/plugins/wpforo-topic-custom-fields/wpforotcf.php

Find this code fragment:

private function field_values_to_string($field){
if( $values = wpfval($field, 'values') ){
if( is_array($values) ) {
if( $field['type'] === 'select' ){
$string = '';
foreach( $field['values'] as $k => $v ){
if( is_array($v) ){
$string .= "\n[optgroup=$k]\n" . implode( "\n", $v ) . "\n[/optgroup]";
}else{
$string .= "\n$v";
}
}
$field['values'] = trim($string);
}else{
$field['values'] = implode("\n", $values);
}
}
}
return $field;
}

 

Replace to this and save:

private function field_values_to_array($field){
if( $values = wpfval($field, 'values') ){
if( is_scalar($values) ) {
$field['values'] = explode( "\n", $values );
if( $field['type'] === 'select' ){
$v = [];
$optgroup = '';
foreach( $field['values'] as $value ){
if( preg_match( '#^ *\[optgroup *= *([^=\]]+?) *] *$#iu', $value, $m ) ){
$optgroup = $m[1];
$v[$optgroup] = [];
}elseif( preg_match( '#^ *\[ */ *optgroup *] *$#iu', $value, $m ) ){
$optgroup = '';
}else{
if( $optgroup ){
$v[$optgroup][] = $value;
}else{
$v[] = $value;
}
}
}
$field['values'] = $v;
}
}
}
return $field;
}
Reply
Share:
Scroll to top