Notifications
Clear all

Problem with html field

16 Posts
4 Users
0 Likes
777 Views
Posts: 6
Customer
Topic starter
(@marios-georgiou)
Member
Joined: 2 years 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
15 Replies
Kyle
Posts: 728
 Kyle
Admin
(@kylew)
Prominent Member
Joined: 3 years 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
Posts: 6
Customer
Topic starter
(@marios-georgiou)
Member
Joined: 2 years 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
Posts: 4168
 Tom
Admin
(@tomson)
Famed Member
Joined: 9 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
Customer
(@marios-georgiou)
Joined: 2 years 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
Admin
(@tomson)
Joined: 9 years ago

Famed Member
Posts: 4168

@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
Customer
(@marios-georgiou)
Joined: 2 years 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
Admin
(@tomson)
Joined: 9 years ago

Famed Member
Posts: 4168

@marios-georgiou,

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

Reply
Posts: 4168
 Tom
Admin
(@tomson)
Famed Member
Joined: 9 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
7 Replies
Customer
(@marios-georgiou)
Joined: 2 years 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
Admin
(@tomson)
Joined: 9 years ago

Famed Member
Posts: 4168

@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
Customer
(@lynne-benedict)
Joined: 2 years ago

Member
Posts: 32

@tomson I do not see the same options shown in your screenshot ???

But I really would LOVE to have the ability to control who can see custom fields. In fact I had this topic opened asking this same question: https://gvectors.com/forum/wpforo-topic-custom-fields/readonly-vs-editable-custom-fields-based-on-user-role/

not seeing
Reply
Kyle
 Kyle
Admin
(@kylew)
Joined: 3 years ago

Prominent Member
Posts: 728

@lynne-benedict,

Please double-check that the field type is "Dropdown".

Reply
Customer
(@lynne-benedict)
Joined: 2 years ago

Member
Posts: 32
wpForo current version

@kylew It does not show up in dropdown. See screenshot attached

drop down field with no options
Reply
Customer
(@lynne-benedict)
Joined: 2 years ago

Member
Posts: 32

@kylew - Was wondering if you saw my last update. Thank you

Reply
Kyle
 Kyle
Admin
(@kylew)
Joined: 3 years ago

Prominent Member
Posts: 728

@lynne-benedict,

Yes I have checked it, for now we cannot you with that as the addon doesn't have the functionality that you are looking for. 

You should use the Dropdown with its functionality for now.

Reply
Share:
Scroll to top