/** * Save a tag set. */ public function actionSaveTagSet() { $this->requirePostRequest(); craft()->userSession->requireAdmin(); $tagSet = new TagSetModel(); // Set the simple stuff $tagSet->id = craft()->request->getPost('tagSetId'); $tagSet->name = craft()->request->getPost('name'); $tagSet->handle = craft()->request->getPost('handle'); // Set the field layout $fieldLayout = craft()->fields->assembleLayoutFromPost(false); $fieldLayout->type = ElementType::Tag; $tagSet->setFieldLayout($fieldLayout); // Save it if (craft()->tags->saveTagSet($tagSet)) { craft()->userSession->setNotice(Craft::t('Tag set saved.')); $this->redirectToPostedUrl($tagSet); } else { craft()->userSession->setError(Craft::t('Couldn’t save the tag set.')); } // Send the tag set back to the template craft()->urlManager->setRouteVariables(array('tagSet' => $tagSet)); }