{
    "content": [
        {
            "type": "text",
            "text": "# CGI::FormBuilder::Source::File (perldoc)\n\n## NAME\n\nCGI::FormBuilder::Source::File - Initialize FormBuilder from external file\n\n## SYNOPSIS\n\n# use the main module\nuse CGI::FormBuilder;\nmy $form = CGI::FormBuilder->new(source => 'form.conf');\nmy $lname = $form->field('lname');  # like normal\n\n## DESCRIPTION\n\nThis parses a file that contains FormBuilder configuration options, and returns a hash suitable\nfor creating a new $form object. Usually, you should not use this directly, but instead pass a\n$filename into \"CGI::FormBuilder\", which calls this module.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **METHODS**\n- **NOTES**\n- **SEE ALSO**\n- **REVISION**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "CGI::FormBuilder::Source::File",
        "section": "",
        "mode": "perldoc",
        "summary": "CGI::FormBuilder::Source::File - Initialize FormBuilder from external file",
        "synopsis": "# use the main module\nuse CGI::FormBuilder;\nmy $form = CGI::FormBuilder->new(source => 'form.conf');\nmy $lname = $form->field('lname');  # like normal",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 102,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 43,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REVISION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "CGI::FormBuilder::Source::File - Initialize FormBuilder from external file\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "# use the main module\nuse CGI::FormBuilder;\n\nmy $form = CGI::FormBuilder->new(source => 'form.conf');\n\nmy $lname = $form->field('lname');  # like normal\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This parses a file that contains FormBuilder configuration options, and returns a hash suitable\nfor creating a new $form object. Usually, you should not use this directly, but instead pass a\n$filename into \"CGI::FormBuilder\", which calls this module.\n\nThe configuration format steals from Python (ack!) which is sensitive to indentation and\nnewlines. This saves you work in the long run. Here's a complete form:\n\n# form basics\nmethod: POST\nheader: 1\ntitle:  Account Information\n\n# define fields\nfields:\nfname:\nlabel:   First Name\nsize:    40\n\nminit:\nlabel:   Middle Initial\nsize:    1\n\nlname:\nlabel:   Last Name\nsize:    60\n\nemail:\nsize:    80\n\nphone:\nlabel:    Home Phone\ncomment:  (optional)\nrequired: 0\n\nsex:\nlabel:   Gender\noptions: M=Male, F=Female\njsclick: javascript:alert('Change your mind??')\n\n# custom options and sorting sub\nstate:\noptions:  \\&getstates\nsortopts: \\&sortstates\n\ndatafile:\nlabel:   Upload Survey Data\ntype:    file\ngrowable:   1\n\n# validate our above fields\nvalidate:\nemail:  EMAIL\nphone:  /^1?-?\\d{3}-?\\d{3}-?\\d{4}$/\n\nrequired: ALL\n\n# create two submit buttons, and skip validation on \"Cancel\"\nsubmit:  Update, Cancel\njsfunc:  <<EOJS\n// skip validation\nif (this.submit.value == 'Cancel') return true;\nEOJS\n\n# CSS\nstyleclass: acctInfoForm\nstylesheet: /style/acct.css\n\nAny option that FormBuilder accepts is supported by this configuration file. Basically, any time\nthat you would place a new bracket to create a nested data structure in FormBuilder, you put a\nnewline and indent instead.\n\nMultiple options MUST be separated by commas. All whitespace is preserved intact, so don't be\nconfused and do something like this:\n\nfields:\nsendmeemails:\noptions: Yes No\n\nWhich will result in a single \"Yes No\" option. You want:\n\nfields:\nsendmeemails:\noptions: Yes, No\n\nOr even better:\n\nfields:\nsendmeemails:\noptions: 1=Yes, 0=No\n\nOr perhaps best of all:\n\nfields:\nsendmeemails:\noptions: 1=Yes Please, 0=No Thanks\n\nIf you're confused, please join the mailing list:\n\nfbusers-subscribe@formbuilder.org\n\nWe'll be able to help you out.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new()\nThis creates a new \"CGI::FormBuilder::Source::File\" object.\n\nmy $source = CGI::FormBuilder::Source::File->new;\n\nAny arguments specified are taken as defaults, which the file then overrides. For example, to\nalways turn off \"javascript\" (so you don't have to in all your config files), use:\n\nmy $source = CGI::FormBuilder::Source::File->new(\njavascript => 0\n);\n\nThen, every file parsed by $source will have \"javascript => 0\" in it, unless that file has a\n\"javascript:\" setting itself.\n\nparse($source)\nThis parses the specified source, which is either a $file, \"\\$string\", or \"\\@array\", and returns\na hash which can be passed directly into \"CGI::FormBuilder\":\n\nmy %conf = $source->parse('myform.conf');\nmy $form = CGI::FormBuilder->new(%conf);\n\nwritemodule($modname)\nThis will actually write a module in the current directory which you can then use in subsequent\nscripts to get the same form:\n\n$source->parse('myform.conf');\n$source->writemodule('MyForm');    # write MyForm.pm\n\n# then in your Perl code\nuse MyForm;\nmy $form = MyForm->new;\n\nYou can also override settings from \"MyForm\" the same as you would in FormBuilder:\n\nmy $form = MyForm->new(\nheader => 1,\nsubmit => ['Save Changes', 'Abort']\n);\n\nThis will speed things up, since you don't have to re-parse the file every time. Nice idea\nPeter.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "This module was completely inspired by Peter Eichman's \"Text::FormBuilder\", though the syntax is\ndifferent.\n\nRemember that to get a new level in a hashref, you need to add a newline and indent. So to get\nsomething like this:\n\ntable => {cellpadding => 1, cellspacing => 4},\ntd    => {align => 'center', bgcolor => 'gray'},\nfont  => {face => 'arial,helvetica', size => '+1'},\n\nYou need to say:\n\ntable:\ncellpadding: 1\ncellspacing: 4\n\ntd:\nalign: center\nbgcolor: gray\n\nfont:\nface: arial,helvetica\nsize: +1\n\nYou get the idea...\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "CGI::FormBuilder, Text::FormBuilder\n",
                "subsections": []
            },
            "REVISION": {
                "content": "$Id: File.pm 100 2007-03-02 18:13:13Z nwiger $\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Copyright (c) Nate Wiger <http://nateware.com>. All Rights Reserved.\n\nThis module is free software; you may copy this under the terms of the GNU General Public\nLicense, or the Artistic License, copies of which should have accompanied your Perl kit.\n",
                "subsections": []
            }
        }
    }
}