Jump to content

How to add an editor to a plugins settings?


VizionDev

Recommended Posts

Posted

I have the following:

//<?php

$editing = NULL;
if ( \IPS\Request::i()->id )
{
	try
	{
		$editing = \IPS\app\Thing::load( \IPS\Request::i()->id );
	}
	catch ( \OutOfRangeException $e )
	{
		var_dump(\IPS\Output::i()->error( 'error' ));
	}
}

$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Editor( 'col1_content', NULL, TRUE, array( 'app' => 'app', 'key' => 'Key', 'autoSaveKey' => $editing ? 'creating-thing' : "editing-thing-{$editing->id}", 'attachIds' => $editing ? array( $editing->id ) : NULL ) ) );

if ( $values = $form->values() )
{
	if ( !$editing )
	{
		$item = new \IPS\app\Thing;
		$item->content = $values['col1_content'];
		$item->save();
		
		\IPS\File::claimAttachments( 'creating-thing', $item->id );
	}
	else
	{
		$editing->content = $values['col1_content'];
		$editing->save();
	}
}

return $form;

Which is documented in https://community.invisionpower.com/4docs/advanced-usage/development/editor-r78/

However I get the following:

dTwO4EM.png

 

Any ideas?

 

Posted

Ok so worked out you don't need most of the above.

$form->add( new \IPS\Helpers\Form\Editor( 'col1_content', \IPS\Settings::i()->col1_content, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'col1_content' ) ) );

Does the trick without all the other junk

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...