]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - support/doc/plugins/guide.md
Enhance plugin video fields
[github/Chocobozzz/PeerTube.git] / support / doc / plugins / guide.md
index 26fcb8987793c826b988901991ed0646161c534b..5c1f6a2aff2ad1492dddbca07646dfda54c031a3 100644 (file)
@@ -692,16 +692,31 @@ async function register ({ registerVideoField, peertubeHelpers }) {
     type: 'input-textarea',
 
     default: '',
+
     // Optional, to hide a field depending on the current form state
     // liveVideo is in the options object when the user is creating/updating a live
     // videoToUpdate is in the options object when the user is updating a video
     hidden: ({ formValues, videoToUpdate, liveVideo }) => {
       return formValues.pluginData['other-field'] === 'toto'
+    },
+
+    // Optional, to display an error depending on the form state
+    error: ({ formValues, value }) => {
+      if (formValues['privacy'] !== 1 && formValues['privacy'] !== 2) return { error: false }
+      if (value === true) return { error: false }
+
+      return { error: true, text: 'Should be enabled' }
     }
   }
 
+  const videoFormOptions = {
+    // Optional, to choose to put your setting in a specific tab in video form
+    // type: 'main' | 'plugin-settings'
+    tab: 'main'
+  }
+
   for (const type of [ 'upload', 'import-url', 'import-torrent', 'update', 'go-live' ]) {
-    registerVideoField(commonOptions, { type })
+    registerVideoField(commonOptions, { type, ...videoFormOptions  })
   }
 }
 ```