🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

github.com/metakeule/gforms

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/metakeule/gforms

v0.0.0-20120717140742-71a64f7c67f0
Source
Go
Version published
Created
Source

HTML forms for Golang

Installation::

go get github.com/vmihailenco/gforms

Example

Example::

package blog

import (
    "github.com/vmihailenco/gforms"
    "github.com/vmihailenco/gforms/gaeforms"
)

type ArticleForm struct {
    *gforms.BaseForm
    Title    *gforms.StringField
    Text     *gforms.StringField
    IsPublic *gforms.BoolField
    Image    *gaeforms.BlobField
}

func NewArticleForm(article *Article) *ArticleForm {
    title := gforms.NewStringField()
    title.MinLen = 1
    title.MaxLen = 500

    text := gforms.NewTextareaStringField()
    text.MinLen = 1

    isPublic := gforms.NewBoolField()
    isPublic.IsRequired = false
    isPublic.Label = "Is public?"

    image := gaeforms.NewBlobField()

    if article != nil {
        title.SetInitial(article.Title)
        text.SetInitial(article.Text())
        isPublic.SetInitial(article.IsPublic)
    }

    f := &ArticleForm{
        BaseForm: &gforms.BaseForm{},
        Title:    title,
        Text:     text,
        IsPublic: isPublic,
        Image:    image,
    }
    gforms.InitForm(f)

    return f
}

FAQs

Package last updated on 17 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts