YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUICompressor
  • YUIDoc
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

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)

    Last Updated: 12/3/09
    + 2 -

    Greg Hinch

    YUI Contributor

    See 2 more by this user.

    Created: 10/28/09
    Last CDN Push: 12/8/09
    Build Tag: gallery-2009.12.08-22
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    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:
    • greghinch
    • form
    • validation
    • 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

    YUI({
        modules: {
            'gallery-form': {
                fullpath: 'http://yui.yahooapis.com/gallery-2009.12.08-22/build/gallery-form/gallery-form-min.js',
                requires: ['node','attribute','widget','io-form','substitute'],
                optional: [],
                supersedes: []
          }
     
        }
    }).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({
            contentBox: '#testForm',
            action : 'test.php',
            method : 'post'
            fields : [
                myField,
                // Have the Form class create your fields itself
                {name : "testText", required : true, label : "Test Label"},
                {name : 'testHiddenField', type : "hidden"},
                {name : 'testSelectField', type : 'select', choices : [{label : 'Foo', value : 'foo'}, {label : 'Bar', value : 'bar'}], label : 'testSelect'},
                {name : 'submit', type : 'submit', label : 'Submit'},
                {name : 'reset', type : 'reset', label : '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? 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 12/18/09
    Re: Suggestions: my wishlist 01/4/10
    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUIDoc
    • YUICompressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits