X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=support%2Fdoc%2Fplugins%2Fguide.md;h=5c1f6a2aff2ad1492dddbca07646dfda54c031a3;hb=3c065fe3b3e1385d59ad1980251d14b712648155;hp=26fcb8987793c826b988901991ed0646161c534b;hpb=61cc1c03bf6f12af7c1b2e2a7d2fdaa563c37b59;p=github%2FChocobozzz%2FPeerTube.git diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 26fcb8987..5c1f6a2af 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md @@ -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 }) } } ```