content: import React from 'react';
  
  /**
   * Produces an HTML form entity.
   */
  export default class Form extends React.Component {
      static displayName = 'Form';
  
      static propTypes = {
          'action': React.PropTypes.string.isRequired,
          'method': React.PropTypes.oneOf(['get', 'post', 'put']),
          'overrideProperty': React.PropTypes.string,
          'encType': React.PropTypes.oneOf(['text', 'multipart']),
          'onSubmit': React.PropTypes.func,
          'children': React.PropTypes.any
      };
  
      static defaultProps = {
          'method': 'post',
          'overrideProperty': '_method'
      };
  
      /**
       * Build an instance.
       */
      constructor() {
          super();
          this.onSubmit = this.onSubmit.bind(this);
          this.getEncType = this.getEncType.bind(this);
          this.getFormMethod = this.getFormMethod.bind(this);
          this.getMethodOverrideElement = this.getMethodOverrideElement.bind(this);
      }
  
      /**
       * Calls the onSubmit prop function, if provided, when the form is
       * submitted.
       * @param {Object} e - The React event
       */
      onSubmit(e) {
          if (this.props.onSubmit) {
              this.props.onSubmit(e);
          }
      }
  
      /**
       * Determines the encoding type of the form.
       * See https://www.ietf.org/rfc/rfc1867.txt
       * @returns {String} - The mime type to specify in th enctype attribute
       */
      getEncType() {
          if (this.props.encType === 'text') {
              return 'text/plain';
          }
          if (this.props.encType === 'multipart') {
              return 'multipart/form-data';
          }
          return this.props.encType;
      }
  
      /**
       * Determines the HTTP method to use when submitting the form.
       * See https://www.ietf.org/rfc/rfc1867.txt
       * @returns {String} - The http method to use
       */
      getFormMethod() {
          if (['get', 'post'].indexOf(this.props.method) !== -1) {
              return this.props.method;
          }
          return 'post';
      }
  
      /**
       * Produces a hidden element which provides the opportunity to emulate
       * http methods other than GET and POST. Requires that the server receiving
       * the request support method overriding.
       * @returns {Object} - A React element
       */
      getMethodOverrideElement() {
          if (['get', 'post'].indexOf(this.props.method) !== -1) {
              return null;
          }
          return (
              <input type="hidden"
                      name={ this.props.overrideProperty || '_method' }
                      value={ this.props.method } />
          );
      }
  
      /**
       * Builds the props that are to be passed through to the form element. We
       * need to get rid of some props that aren't supported by the form element,
       * so we take that opportunity here.
       * @returns {Object} - The final props object
       */
      getProps() {
          const props = Object.assign({}, this.props, {
              'encType': this.getEncType(),
              'method': this.getFormMethod(),
              'onSubmit': this.onSubmit
          });
          delete props.overrideProperty;
          return props;
      }
  
      /**
       * Perform render
       * @returns {Object} - A React element
       */
      render() {
          const props = this.getProps();
          return (
              <form { ...props }>
                  { this.getMethodOverrideElement() }
                  { this.props.children }
              </form>
          );
      }
  
  }