• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Form (gallery-form) on cdn

    Last Updated: 05/14/12
    + 1 -

    Greg Hinch

    YUI Contributor

    See 14 more by this user.

    Created: 10/28/09
    Last CDN Push: 11/10/11
    Build Tag: gallery-2011.11.10-16-24
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.6.0pr1
    Free for use.

    The Form module allows for the programmatic creation of form and form field nodes. The available field nodes are TextField, HiddenField, CheckboxField, SelectField, ChoiceField, TextAreaField, and Buttons (a much less robust version than YUI 2's Button module). Fields can be manually instantiated and added to your Form, or configuration parameters may be passed directly when creating the Form and it will generate your Fields for you. There is also limited HTML parsing ability to pull in your Form data, but it is not yet fully baked.

    • Tags:
    • validation
    • form
    • greghinch
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    This shows how you can create a Field object manually, and then use it while creating a form that also contains a number of Fields to be generated based on the supplied configuration parameters.

    Code Sample

    <script src="http://yui.yahooapis.com/3.6.0pr1/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2011.11.10-16-24'
    }).use("gallery-form", function (Y) {
        // Create a Field Object manually
        var myField = new Y.CheckboxField({
            name : "myCheckbox",
            value : "check",
            label : "Test Checkbox"
        });
     
        var f = new Y.Form({
            boundingBox: '#form',
            action : 'test.php',
            method : 'post',
            children : [
                myField,
                // Have the Form class create your fields itself
                {name : "testText", required : true, label : "Test Label"},
                {name : 'testHiddenField', type : "HiddenField"},
                {name : 'testSelectField', type : 'SelectField', choices : [{label : 'Foo', value : 'foo'}, {label : 'Bar', value : 'bar'}], label : 'testSelect'},
                {name : 'submitBtn', type : 'SubmitButton', value : 'Submit'},
                {name : 'resetBtn', type : 'ResetButton', value : 'Reset'}
            ]
        });
     
        f.subscribe('success', function (args) {
            alert ('Form submission successful');
        });
        f.subscribe('failure', function (args) {
            alert('Form submission failed');
        });
     
        f.render();
    });
     

    Forum Posts

    Subject Author Date
    Which validators built in? Greg Hinch 11/2/09
    Re: Which validators built in? Dav Glass 11/3/09
    Re: Which validators built in? Viktor Rennert 11/3/09
    Field events Eike Hirsch 11/8/09
    Re: Field events Greg Hinch 11/10/09
    Re: Field events Eike Hirsch 11/11/09
    New Version Available Greg Hinch 11/15/09
    multipart / file field Raphaël Bauduin 12/15/09
    Suggestions: my wishlist Satyam 12/18/09
    Re: Suggestions: my wishlist Joe Developer 01/4/10

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info