Jump to content
Inxentas

CKEditor for module config

Recommended Posts

Hi there! I'm writing a module for a website, and it needs to store a bit of text. This works fine:

$inputfields = parent::getInputfields();
$message = $this->modules->get('InputfieldTextarea');
$message->attr('name', 'message');
$message->label = 'Message';
$message->required = true;
$message->set("inputfieldClass", "InputfieldCKEditor");
$inputfields->add($message);

...except the part about the inputfieldClass. Is it possible to make these fields have a "CKEditor" instead? My client would need to add a little markup.

Share this post


Link to post
Share on other sites

Just use InputfieldCKEditor directly instead of InputfieldTextarea. You're talking about direct application of Inputfields here. The inputfieldClass needs to be set if you are attaching a field (a FieldtypeTextarea, not InputfieldTextarea) to a template for use in pages.

Share this post


Link to post
Share on other sites

Wow, thanks for your speedy reply @BitPoet! This worked like a charm. I didn't realize the input class was only required for templates. Will this play nice with multi language websites, by the way? I might was well implement multi language support right away.

Share this post


Link to post
Share on other sites

You're welcome. You can set the useLanguages flag on the CKEditor field to get multi language support.

$message->useLanguages = true;

The only thing you need to aware of is that, as far as I know, there is no fallback to the default language's value if the value in the current language is empty.

Share this post


Link to post
Share on other sites

Amazing how simple ProcessWire stuff can be to implement! Having no fall back is fine, but thanks for that heads up. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...