]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - support/doc/plugins/guide.md
Add ability to hide plugin form fields
[github/Chocobozzz/PeerTube.git] / support / doc / plugins / guide.md
index ca951c781d0ed0552a1fdf98cb535793f2284041..8d85092e79e401dc25fa411a8975bb4e1b231fb4 100644 (file)
@@ -623,7 +623,13 @@ async function register ({ registerVideoField, peertubeHelpers }) {
     label: 'My added field',
     descriptionHTML: 'Optional description',
     type: 'input-textarea',
-    default: ''
+    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'
+    }
   }
 
   for (const type of [ 'upload', 'import-url', 'import-torrent', 'update', 'go-live' ]) {