Inxentas Posted March 13, 2019 Posted March 13, 2019 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.
BitPoet Posted March 13, 2019 Posted March 13, 2019 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.
Inxentas Posted March 14, 2019 Author Posted March 14, 2019 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.
BitPoet Posted March 14, 2019 Posted March 14, 2019 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.
Inxentas Posted March 22, 2019 Author Posted March 22, 2019 Amazing how simple ProcessWire stuff can be to implement! Having no fall back is fine, but thanks for that heads up.
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