Форумы / Cotonti / Bugs / Custom extrafield bug + cot_inputbox

cot_inputbox resetting custom html code for extrafield

Eugene
#1 11.03.2013 10:59

When updating/customizing extrafield html code in admin area - it goes to DB (cot_extra_fields) as "field_html".
Later this content is used to build inputbox (extrafields.php -> function cot_build_extrafields). On line #36 this html goes to cot_inputbox while it is expecting just a custom name of $rc - NOT the html code itself (forms.php #67-69)
So, later it is just replaced with 'input_default'.

Exaple of the code I play with in admin area of extrafields for Pages is
 

<input required="required"  type="text" name="{$name}" value="{$value}" {$attrs} />

or

<input type="number" name="{$name}" value="{$value}" {$attrs} />


We need clarity on customization proccess. We need to be able to both:

  1. Create custom $R[input_{$type}_{$rc_name}] in our plugins
  2. Customize html mask in admin area (this is very beneficial for newbies)
Trustmaster
#2 11.03.2013 12:49

Any ideas on how to set priorities between these 2?

May the Source be with you!
Eugene
#3 11.03.2013 15:19

2 option is higher priority for the sake of clarity in administration/tuning...

As i understand we cannot change last argument of function cot_inputbox (and selectbox) for backward compatibility. Right?
So, there just a need to assign some RC_name to the html mask from admin area and pass it to functions... But where to store this name? Code is stored right in DB...

I'm sure, there's another option of checking things right in cot_inputbox....

Добавлено 2 дня спустя:

Trust, do you want me to add this to GitHub?

Отредактировано: Eugene (13.03.2013 21:15, 11 лет назад)
Trustmaster
#4 15.03.2013 18:48

Priorities are actually fine. It's a small bug in cot_inputbox() function which doesn't let you set custom_rc. I'll fix it shortly.

May the Source be with you!
Eugene
#5 15.03.2013 22:03

it would be awesome!

btw, i guess the same mechanism is in cot_selectbox...

Trustmaster
#6 16.03.2013 07:53

For selectbox you can only use custom HTML for the select itself but not options.

May the Source be with you!
Eugene
#7 16.03.2013 13:09

Yes, and let me clarify a problem, cause you can advise a solution.

As you know there's no placeholder for select. And there several ways to emulate it. Simple html-way is to include empty-value-option into select before all other selects. So, there's line for custom select in RC:

$R['input_select_rpageoptik'] = '<select required name="{$name}"{$attrs}>'.
	'<option label="Jede Optik" value="" selected="selected"  >Jede Optik</option>'.
	'{$options}</select>{$error}';

But in cot_selectbox selected is already build-in and always assign to one of assigned options. This way I will have 2 selected options. Also, as empty-value-option is not in array of assigned values I will get error (field_notinarray_..) from extrafield_import...

You may say, "so, add empty value by $add_empty = true".  But it is not possible, cause it also not custom in cot_build_extrafields.

Moreover, there is no way to create custom $R['code_option_empty'] for some custom selectbox.... it is "---" (default) for all empty options in selects...

Trustmaster
#8 16.03.2013 18:06

This is not a bug, this is how it is supposed to work. It is a new feature that you are missing: custom empty options and default options for selects. It should be implemented explicitly in cot_selectbox() function, or you could implement it as your own function.

May the Source be with you!