Set Unpublished Page by default with Plugin Add by Form

Hi,

I’m trying to setup the plugin add by form to configure a way to write posts of blog from frontend.

I’ve read the plugin documentation and I’ve got to configure correctly it, but I’d like that the new posts were saved unpublished.

My code is this:

title: 'Add post'
template: addpage
pageconfig:
    parent: /blog
    include_username: false
    overwrite_mode: true
pagefrontmatter:
    template: item
    title: 'New post'
    taxonomy:
        category: blog
form:
    name: addpage.blogpost
    fields:
        -
            name: title
            label: Title
            type: text
            validate:
                required: true
        -
            name: metadata.description
            label: Description
            type: text
            validate:
                required: true
        -
            name: metadata.author
            label: Author
            type: text
            validate:
                required: true
        -
            name: taxonomy.tag
            label: 'Tags'
            type: text
            validate:
                required: true
        -
            name: content
            label: 'Post Content'
            type: textarea
            size: long
            classes: editor
            validate:
                required: true
        -
            name: honeypot
            type: honeypot
    buttons:
        -
            type: submit
            value: Submit
    process:
        -
            addpage: null
        -
            redirect: /blog
access:
    site.login: true

I’ve tried this:

       -
            name: published
            type: toggle
            disabled: true
            default: false
            label: 'Published'
            highlight: 1
            options:
                1: 'Si'
                0: 'No'
            validate:
                type: bool

I don’t know if this is possible from the .md file, but others fields, such as metadata.title or metadata.author works fine.

Thanks in advance

Hello again

I’ve just to solved this problem. I’m going to share my code if anyone want to use it:

---
title: 'Añadir entrada de blog'
template: addpage
pageconfig:
    parent: /blog
    include_username: false
    overwrite_mode: true
pagefrontmatter:
    template: item
    title: 'Nueva entrada'
    taxonomy:
        category: blog
form:
    name: addpage.blogpost
    fields:
        -
            name: title
            label: Titulo
            type: text
            classes: text-addform
            validate:
                required: true
        -
            name: metadata.description
            label: Descripción
            type: text
            validate:
                required: true
        -
            name: metadata.author
            label: Autor
            type: text
            validate:
                required: true
        -
            name: taxonomy.tag
            label: 'Etiquetas (senderismo, alpinismo, ferratas, travesías)'
            type: text
            validate:
                required: true
        -
            name: style
            label: 'Selecciona el color para el tipo de actividad <br>(senderismo --> <span style="color: #318d0c;">success</span>, ferratas --> <span style="color: #9c0303;">danger</span> o alpinismo --> <span style="color: #03979c;">info</span>)'
            type: text
            
        -
            name: published
            label: Publicado
            type: toggle
            default: 0
            options:
                1: 'Si'
                0: 'No'  
            validate:
                type: bool
        -
            name: publish_date
            type: date
            label: 'Fecha de publicación'
        -
            name: date
            type: date
            label: 'Fecha de la actividad'
        # -
        #     name: image_file
        #     label: 'Imagen de cabecera de la entrada'
        #     type: file
        #     multiple: false
        #     destination: '@self'
        #     accept:
        #         - image/*
        -
            name: content
            label: 'Contenido de la entrada'
            type: textarea
            size: long
            classes: editor
            validate:
                required: true
        -
            name: honeypot
            type: honeypot
    buttons:
        -
            type: submit
            value: Enviar
    process:
        -
            addpage: null
        -
            redirect: /blog
access:
    site.login: true
---

## Complete el formulario para añadir una nueva entrada de Blog

Sorry, I’m Spanish and I wrote all in my language. I hope you understand good.

However, I want to set an image to header in post, but I can’t do it with the ‘File’ field in the form file. This code appears commented.

Any help for this issue?

Thanks so much.

Thanks for sharing the solution