XF 2.3 How to save editorrow value in ACP option

shqawe

Member
How to save <xf:editorrow /> value when i use it in my addon option. I create a new template for this option with below code:

HTML:
<xf:formrow label="{$option.title}" hint="{$hintHtml}" html="{$listedHtml}">
                                        <xf:editorrow name="option[option_id]" value="{$option.option_value}"
                                            rowtype="fullWidth mergePrev " data-min-height="100" />
                                    </xf:formrow>


But when i try saving no data was saved in database.
 
You should use the editor plugin to save editor input:

PHP:
$editorPlugin = $this->plugin(\XF\ControllerPlugin\EditorPlugin::class);
$editorInput = $editorPlugin->fromInput('your_input_name');

This would require an option validation callback.
 
Thank you @Jeremy P for your reply but this is actually my question how can i use your code with option i mean in \XF\Option\MyAddonOption.php i couldn't use your code in this file.
 
Right sorry, I originally wrote it with a controller in mind. I haven't tested this and wouldn't recommend this generally, but you can try instantiating a controller to get the plugin.

PHP:
$optionController = \XF::app()->controller(
    \XF\Admin\Controller\Option::class, 
    \XF::app()->request()
);
$editorPlugin = $optionController->plugin(\XF\ControllerPlugin\EditorPlugin::class);
$editorInput = $editorPlugin->fromInput('your_input_name');
 
Back
Top Bottom