XF 2.1 Easier method to incorporate <xf:editor>

Cupara

Well-known member
I want to incorporate <xf:editor> into an admin template for an add-on I am about to release. The problem is the process I have seen so far is calling a plugin, service, before it ever processes and saves. Then reversing that to properly display the bbcode on the page. Is there an easier method to do this? One that I could use in my add-on to get it where it needs to be.
 
@batpool52! I'm trying to add the editor to my add-on for certain fields such as banner_text which can be a paragraph containing bbcode.

I get the editor to show but parsing it properly so it is inserted into the table and parsed properly when it is pulled is where I'm having issues.
 
You'll need to make sure your option's edit format is set to Template, then the contents of whatever template you end up using it should end up something looking like this:

HTML:
<xf:editorrow name="{$inputName}" value="{$option.option_value}"
    label="{$option.title}"
    hint="{$hintHtml}"
    explain="{$explainHtml}" />

Then you will need to parse the editor message using the validation callback.
 
Then you will need to parse the editor message using the validation callback.
How we could this?
I added Scandals\{id}\Option\BBCodeEditor::verifyOption as validation class, but it verifyOption never runs.
Even if I write this:
PHP:
class BBCodeEditor
{
    public static function verifyOption(&$value, \XF\Entity\Option $option, $optionId)
    {
        $option->error('test');
        return false;      
    }  
}
... system is still able to continue the save process, with no option_value.
It seems that the template nevers passes the options[{varname}] value.

My template:
HTML:
<xf:editorrow name="{$inputName}"
    value="{$option.option_value}"
    label="{$option.title}"
    hint="{$hintHtml}"
    explain="{$explainHtml}" />
Edit format: Named Template
Format parameters: my_template_name
Data type: String
 
Back
Top Bottom