Inxentas Posted June 20, 2022 Share Posted June 20, 2022 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 More sharing options...
Studio Lambelet Posted June 20, 2022 Share Posted June 20, 2022 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>"; 2 Link to comment Share on other sites More sharing options...
Inxentas Posted June 21, 2022 Author Share Posted June 21, 2022 Ah, thanks a lot! I was trying to configure an InputfieldTextarea as one would do in the CMS itself and couldn't get it to render. Using the right class worked very well. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now