Jump to content

How to create new field which uses FieldtypeTextarea as type and InputfieldTinyMCE as inputfield


Gayan Virajith
 Share

Recommended Posts

Hello community,
 
I am trying to create a field using API. Basically field should have a type of FieldtypeTextarea  and InputfieldTinyMCE as inputfield.
 
Here is my code :

/* Create new field using API */
$field = new Field();
// Set type as FieldtypeTextarea
$field->type = $this->modules->get("FieldtypeTextarea");
// Set inputfield as InputfieldTinyMCE. But no luck
$field->set('inputfield', 'InputfieldTinyMCE');
// Name of the field
$field->name = 'footer_region';
// Set label
$field->label = 'Footer region area';
// Save
$field->save();

Above code will create a new field with the type of FieldtypeTextarea. But it want assign InputfieldTinyMCE as the inputfield. 

Any advise please 

Thank you 

Link to comment
Share on other sites

What you're looking for is: inputfieldClass

The easiest way to figure these things out is often to use your browser dev tools. I actually didn't know this initially, but a quick right-click > Inspect Element on the select field under Inputfield Type, revealed the name of the select as: inputfieldClass

Edited by adrian
  • Like 3
Link to comment
Share on other sites

Hi Adrian, 

Thank you so much. Yes that is it. 

Here is the working piece : 

/* Create new field using API */
$field = new Field();
// Set type as FieldtypeTextarea
$field->type = $this->modules->get("FieldtypeTextarea");
// Set inputfield as InputfieldTinyMCE.  Thanks to Adrian
$field->set('inputfieldClass',  "InputfieldTinyMCE");
// name of the field
$field->name = 'footer_region';
// set label
$field->label = 'Footer region area';
        
// Save !
$field->save();

Thanks again Adrian & the community

  • 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

×
×
  • Create New...