Custom Block: Rick Text Editor in form.php (?)

Permalink
OK So my Question is pretty simple:
I want my Custom Block to able to implement the rich text editor while in Edit/Add mode.

I have my Custom Block already created in the **application/blocks/** directory.

Controller, db.xml, view all created and work as expected. My form.php looks like this:
<?php
defined ('C5_EXECUTE') or die(_('Access Denied.'));
$app = Concrete\Core\Support\Facade\Application::getFacadeApplication();
$form = $app->make('helper/form');
$tabs = $app->make('helper/concrete/ui');
// Create our menu tabs
print $tabs->tabs(array(
    array('accordians', t('Accordians'), true)
)); 
?>
<fieldset class="tab-content">
    <div class="ccm-tab-content" id="ccm-tab-content-accordians">
        <div class="form-group">
            <?php echo $form->label('accordian_header' , t("Accordian Header")); ?>
            <?php print $form->text('accordian_header', $accordian_header); ?>


Pretty Standard. I want my textarea to become the Rich Text Editor so all the view has to do is output the HTML to the page.
I cannot find in the documentation/ tutorials is a 5.7 way of adding the rich text editor the a custom block and what classes / helpers i need in order for it to work.

Is this possible? What am i missing? (also any critiques are welcome)

 
linuxoid replied on at Permalink Best Answer Reply
linuxoid
Try this:

form.php:
$editor = $app->make('editor');
echo $editor->outputBlockEditModeEditor('text_show', $controller->getTextShow());


controller.php:
use Concrete\Core\Editor\LinkAbstractor;
...
    public function view() 
    {
        $this->set('text_show', LinkAbstractor::translateFrom($this->text_show));
    }
    public function edit()
    {
        $this->set('text_show', LinkAbstractor::translateFrom($this->text_show));
    }
    public function save($args) 
    {
        $args['text_show'] = LinkAbstractor::translateTo($args['text_show']);
        parent::save($args);
    }

There's also a simpler editor:
echo $editor->outputStandardEditor('short_desc', $short_desc);

FYI:https://documentation.concrete5.org/developers/interface-customizati...
aaronStark replied on at Permalink Reply
Ahhh this is exactly what i needed.
Code works perfectly, i used the Standard Editor for now since i don't expect to use more than some basic HTML & formatting but i'll keep the Block Editor just in case new use cases crop up.

Completely missed that documentation, noticed it was under "interface customization" - Big D'oh on my part, good eye.