Jump to content

How to configure InputfieldTextarea properly in a module.


Recommended Posts

Hello everyone,

I'm trying to write a module configuration by extending ModuleConfig. So far so good. I have a nice wrapper going with some inputfields. One of them is a TextArea that I've added as a field to my config class:

$field = wire('modules')->get("InputfieldTextarea");
$field->columnWidth = 100;
$field->attr("id+name", "source_text");
$field->label = "Source Text";
$field->icon = "fa-align-left";

I'm trying to make this a field that accepts HTML instead of plain text, so I want it to use CKEditor and set some options. I couldn't find how to configure that so I made myself a custom field through the CMS so I could take a look at how it's constructed. I figured out I could change it's attributes, but this doesn't seem to work:

$field->attr("inputfieldClass", "InputfieldCKEditor");
$field->attr("contentType", 1);

I'm a bit at a loss as to how I configure this field, since it's part of a module. I've also tried calling getExportData() on the field I made manually, which works and shows the relevant data, but I can't call setImportData() on the $field variable above: this causes an error. I guess because that field isn't saved in the database the way a normal field is.

Can I configure module fields to support HTML? 

 

Link to comment
Share on other sites

Hi Inxentas,

You need to get InputfieldCKEditor instead of InputfieldTextarea.

$field = wire('modules')->get('InputfieldCKEditor');
$field->columnWidth = 100;
$field->attr("id+name", "source_text");
$field->label = "Source Text";
$field->icon = "fa-align-left";
$field->value = "<h1>Yeah HTML!</h1>";
  • Like 2
Link to comment
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
 Share

  • Recently Browsing   0 members

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