I'm developing a plugin which requires certain sections and fields to exist so I'm currently creating them in the
onAfterInstall() method of the plugin.
I can create individual fields, sections, entry types and even a Matrix field + block type fine. I'm having trouble with creating the Matrix sub-field and attaching that field to the Matrix block type.
I have created the matrix field:
$field = new FieldModel(); $field->groupId = $group->id; $field->name = Craft::t('Field Name'); $field->handle = 'handleName'; $field->translatable = false; $field->type = 'Matrix'; craft()->fields->saveField($fieldContentRSS);
And this is the block type:
$blockType = new MatrixBlockTypeModel(); $blockType->fieldId = $field->id; $blockType->name = Craft::t('Block Name'); $blockType->handle = 'handleName'; craft()->matrix->saveBlockType($blockType);
I know that I will need to create a field/set of fields for this block type. Is this exactly the same as the new field above? How do I then attach these fields to the block type?