Feature/forms #1110

Merged
merged 101 commits into from May 15, 2012
Commits on May 11, 2012
  1. @weierophinney

    [zen-46] Created Input interface and implementation

    weierophinney committed Mar 30, 2012
    - Wrote tests describing behavior
    - Wrote interface for Inputs
    - Wrote implementation for Inputs
    - Wrote initial tests for InputFilter
  2. @weierophinney

    [zen-46] Identified all tests for InputFilter, Factory

    weierophinney committed Mar 30, 2012
    - Identified unit tests for InputFilter
    - Identified unit tests for InputFilter Factory
  3. @weierophinney

    [zen-46] InputFilter tests

    weierophinney committed Mar 30, 2012
    - InputFilter tests are mostly complete. Incomplete tests include:
      - conditional validation (i.e., only validate if another input
        passed/failed/is present, etc)
      - ability to pass context to validators
      - Skip validation of fields marked required when no data is present
      - skip validation of required fields when allow empty is true and no
        value is passed
      - invalid data on to required fields when allow empty is false and
        no value is passed
  4. @weierophinney

    Added break-on-failure, error-message fields to Input

    weierophinney committed Apr 3, 2012
    - Added breakOnFailure flag
    - Added errorMessage string
    - Added more tests to InputFilter suite
  5. @weierophinney
  6. @weierophinney

    Created InputFilterInterface

    weierophinney committed Apr 3, 2012
    - Created InputFilterInterface based on test cases
    - Marked one test with a todo -- questioning whether we should change
      the name on an Input, or simply store a hashtable internally
  7. @weierophinney

    [zen-46] initial implementation of InputFilter

    weierophinney committed Apr 3, 2012
    - adding/retrieving input objects
    - setting data to validate
    - partial isValid() implementation
      - fails tests
      - raises questions about nesting input filters, how to mark empty,
        required elements as invalid so as to receive a message
  8. @weierophinney

    [zen-46] completed input retrieval

    weierophinney committed Apr 4, 2012
    - Completed get(Raw)?Values?() implementations
    - All tests now run; failures are for unimplemented functionality around
      partial validation, contextual validation, and retrieval of
      valid/invalid values and error messages
  9. @weierophinney
  10. @weierophinney
  11. @weierophinney
  12. @weierophinney

    [zen-46] Allow passing context to validators

    weierophinney committed Apr 4, 2012
    - Primarily a change in the ValidatorChain, but also a small signature
      chain to the Callback validator to make it clear that context can be
      provided (implementation would already use it)
  13. @weierophinney

    [zen-46] Added todo item

    weierophinney committed Apr 4, 2012
    - How should we deal with required input when data is missing?  should a
      message be returned? if so, what message? Does any message need to be
      returned, as getInvalidInput() will return this input anyways?
  14. @weierophinney

    [zen-46] Completed factory implementation

    weierophinney committed Apr 4, 2012
    - Allows specifying a default filter chain and/or validator chain for
      elements it creates
    - Allows creating input objects from specifications
      - Allows creating filters from specifications
      - Allows creating validators from specifications
    - Allows creating input filter objects from specifications
    - Allows creating nested input filter objects from specifications
    - Updated FilterChain to be Pluggable
    - Updated ValidatorChain to be Pluggable
  15. @weierophinney
  16. @weierophinney
  17. @weierophinney

    [zen-47] Implemented concrete Element class

    weierophinney committed Apr 9, 2012
    - Created test cases for Element behavior
    - Created initial concrete implementation of Element
  18. @weierophinney
  19. @weierophinney

    [zen-47] Initial tests for Fieldset

    weierophinney committed Apr 13, 2012
    - Created initial round of tests for Fieldset
    - Altered interface slightly based on usage desired
  20. @weierophinney

    [zen-47] Completed Fieldset tests

    weierophinney committed Apr 16, 2012
    - Completed all behavior use cases
  21. @weierophinney

    [zen-47] Fieldset implementation

    weierophinney committed Apr 16, 2012
    - Moved set/getMessages to ElementInterface
    - Full implementation of Fieldset
  22. @weierophinney

    [zen-47] Identified various behaviors as test cases

    weierophinney committed Apr 16, 2012
    - Most marked incomplete at this time
  23. @weierophinney

    [zen-47] Form tests (mostly) complete

    weierophinney committed Apr 16, 2012
    - Complete except for test detailing that input filter from model will
      be used when model is InputFilterAware
    - Added Zend\Stdlib\ArraySerializableInterface
    - Added "Hydrator" subclass, per Marco Pivetta's suggestion, to allow
      arbitrary hydration of bound objects
      - Created two initial hydrator types: ObjectProperty (public
        properties of the object), ArraySerializable (classes implementing
        above mentioned ArraySerializableInterface)
  24. @weierophinney

    [zen-47] Completed Form tests

    weierophinney committed Apr 17, 2012
    - Added InputFilterAwareInterface; FormInterface now extends it
    - Added TestAsset\ValidatingModel
  25. @weierophinney

    [zen-47] Tests run

    weierophinney committed Apr 17, 2012
    - but do not pass. :)
    - Ensured all interfaces are properly defined
    - Ensured all test assets are properly defined
    - Initial work on concrete Form class
  26. @weierophinney

    [zen-47] Form implementation

    weierophinney committed Apr 17, 2012
    - must setData() before calling isValid()
    - must isValid() before calling getData()
    - hydration only occurs if data is valid
    - populate value attributes of all elements/fieldsets when data is set
    - allow binding raw values to bound model
    - allow retrieving normalized or raw values with no bound model
    - allow forcing retrieval of data as array with bound model
    - ensure input filter only returns partial set on partial validation
  27. @weierophinney

    [zen-47] Initial Factory scaffolding

    weierophinney committed Apr 18, 2012
    - Created test case file with incomplete tests
    - Created stub class file
  28. @weierophinney

    [zen-47] Element factory

    weierophinney committed Apr 18, 2012
    - Implemented element factory functionality
  29. @weierophinney

    [zen-47] Fieldset factory

    weierophinney committed Apr 18, 2012
    - Implemented fieldset factory (Factory::createFieldset())
      - Allows creation of child elements
      - Allows creation of nested fieldsets
  30. @weierophinney

    [zen-47] Form factory implementation

    weierophinney committed Apr 18, 2012
    - Implemented form factory (Factory::createForm())
      - Added accessors for input filter factory, to allow creating the
        input factory attached to a form
      - Allows elements, nested fieldsets, input filter attachment/creation,
        and hydrator specification
  31. @weierophinney

    [zen-48] Form view helper

    weierophinney committed Apr 19, 2012
    - Created base form view helper
      - Handles doctype, escaping
    - Created base form view helper testcase
      - Tests doctype, escaping
      - ensures helper broker is seeded correctly
    - Created Form view helper
      - includes openTag(FormInterface $form = null) and closeTag() methods
  32. @weierophinney
  33. @weierophinney

    [zen-48] Ensure "id" attribute is present

    weierophinney committed Apr 19, 2012
    - If we have a "name" but no "id", set the "id" to the "name"
  34. @weierophinney

    [zen-47] Rename element to alias

    weierophinney committed Apr 19, 2012
    - If providing an alias in the flags when adding an element/fieldset,
      set its name to that alias. This is the only way we can ensure
      rendering will follow the structure provided in the form hierarchy
  35. @weierophinney

    [zen-48] Created FormLabel view helper tests

    weierophinney committed Apr 19, 2012
    - Suggested use cases:
      - echo $this->formLabel()->openTag() . $this->translate('Label for
        element') . $this->formElement($element) .
        $this->formLabel()->closeTag();
      - echo $this->formLabel()->openTag($element) . $this->translate('Label for
        element') . $this->formLabel()->closeTag();
      - echo $this->formLabel($element, $this->translate('Label for element'))
      - echo $this->formLabel($element, $this->formText($element),
        'append')
      - Basic idea is to allow each of the following styles of markup:
        - <label>This is a label:<input type="text" id="foo" /></label>
        - <label for="foo">This is a label:</label> ... <input ... />
        - <label for="foo"><input ... />This is a label:</label>
  36. @weierophinney

    [zen-48] FormLabel view helper implementation

    weierophinney committed Apr 19, 2012
    - Wrote implementation to follow usage defined in tests
    - Added getId(ElementInterface $element) to AbstractHelper
  37. @weierophinney

    [zen-48] Created TODO list

    weierophinney committed Apr 19, 2012
    - Shows must haves for beta4
    - Details roadmap for additional view helpers in the future
  38. @weierophinney

    [zen-48] FormInput view helper tests

    weierophinney committed Apr 20, 2012
    - Created full test case for FormInput view helper
  39. @weierophinney

    [zen-48] working FormInput view helper implementation

    weierophinney committed Apr 20, 2012
    - Added feature to AbstractHelper to scrub unknown/unwanted attributes
    - Added feature to AbstractHelper to cast boolean attribute values to
      appropriate strings
    - Added feature to AbstractHelper for retrieving inline tag close string
    - Fully working FormInput implementation
    - Known issue: changes in AbstractHelper break existing helpers
  40. @weierophinney

    [zen-48] Added attributes for form, label

    weierophinney committed Apr 20, 2012
    - Added accept-charset, action, enctype, for, method, novalidate, target
      to list of valid attributes; fixes failures in Form and FormLabel
      tests
  41. @weierophinney

    [zen-48] update helper list

    weierophinney committed Apr 20, 2012
    - Updated Zend\Form\View\HelperLoader to provide FormInput and FormLabel
  42. @weierophinney

    [zen-48] Refactored attribute support

    weierophinney committed Apr 20, 2012
    - Two lists: validGlobalAttributes, and validTagAttributes
      - validGlobalAttributes are valid for all tag types
      - validTagAttributes will be set by individual extensions to indicate
        additional attributes valid for that tag
    - Updated Form, FormLabel, and FormInput implementations and tests
  43. @weierophinney

    [zen-48] Implemented FormElementErrors view helper

    weierophinney committed Apr 20, 2012
    - Creates flat list of all validation messages present in an element
    - Allows modifying the markup
  44. @weierophinney
  45. @weierophinney
  46. @weierophinney

    [zen-48] Created FormMultiCheckbox helper

    weierophinney committed Apr 26, 2012
    - Allows custom separators
    - Allows specifying position of label in relation to checkbox
    - Will mark boxes checked based on element value
  47. @weierophinney

    [zen-48] Added FormRadio view helper

    weierophinney committed Apr 27, 2012
    - Extends FormMultiCheckbox, and simply redefines getInputType()
  48. @weierophinney

    [zen-48] Completed FormSelect view helper

    weierophinney committed Apr 27, 2012
    - Can create <select> elements with <option> and <optgroup> children
    - Labels are rendered as content of an option
    - allows disable, selected, and multiple
  49. @weierophinney

    [zen-48] Updated HelperLoader for Form view helpers

    weierophinney committed Apr 27, 2012
    - Added radio, select, and multi-checkbox helpers
  50. @weierophinney

    Created CSRF validator

    weierophinney committed May 3, 2012
    - handles session injection and expiration hops
    - performs validation against stored session value
  51. @weierophinney

    Initial refactor of Zend\Captcha

    weierophinney committed May 3, 2012
    - Renamed interfaces
    - Modified interface: s/getDecorator/getHelperName/, removed render()
    - Working Captcha\Dumb tests
    - Need to complete other captcha tests
  52. @weierophinney
  53. @weierophinney
  54. @weierophinney
  55. @akrabat @weierophinney
  56. @weierophinney

    Refactored Zend\Captcha

    weierophinney committed May 8, 2012
    - Removed all rendering capabilities
      - however, has a "getHelperName" to hint to the renderer what helper
        to use
    - Created form-specific captcha view helpers for rendering captchas from
      elements
  57. @weierophinney

    Added FormCaptcha view helper

    weierophinney committed May 8, 2012
    - Delegates to the view helper returned by $captcha->getHelperName()
  58. @weierophinney

    [ZF2-290] Do not render false boolean attribute values

    weierophinney committed May 8, 2012
    - unless "false" is indicated by something other than an empty string
  59. @weierophinney

    Added Captcha\Factory

    weierophinney committed May 8, 2012
    - Created to make creating captcha element from factory possible
  60. @weierophinney

    Created captcha element

    weierophinney committed May 8, 2012
    - Defines accessor/mutator for captcha adapter (proxying to attribute)
    - Allows defining captcha adapter via factory
  61. @weierophinney

    [zen-12] Created input/filter provider interfaces

    weierophinney committed May 9, 2012
    - Zend\InputFilter\InputProviderInterface -- to return a specification
      that can be used to create an input for the given object
    - Zend\InputFilter\InputFilterProviderInterface -- to return a specification
      that can be used to create an input filter for the given object
  62. @weierophinney

    [zen-12] loosened type restriction on FieldsetInterface::add()

    weierophinney committed May 9, 2012
    - Removed typehint of ElementInterface, in order to allow a
      factory-backed fieldset/form implementation
  63. @weierophinney

    [zen-12] Create factory-backed form implementation

    weierophinney committed May 9, 2012
    - Moved base form implementation to BaseForm
    - Added "create()" method to Factory; allows creating elements,
      fieldsets, or forms, based on "type" parameter provided
    - Created FormFactoryAwareInterface, for composing form factories
    - Created new "Form" implementation that is factory-backed
      - implements FormFactoryAwareInterface
      - overrides add() to create elements/fieldsets from specs before
        attaching
  64. @weierophinney

    [zen-12] Initial input marshalling

    weierophinney committed May 9, 2012
    - Updated InputFilterInterface to define has()
    - Form now defines attachInputFilterDefaults(), called from
      getInputFilter()
      - iterates through elements
      - if element implements InputProviderInterface, and input filter does
        not have an input by that name, generates an input from the returned
        specification and attaches to the input filter
    - TODO: similar logic for fieldsets (InputFilerProviderInterface)
  65. @weierophinney

    [zen-12] Developed algorithm for scanning fieldsets for input filters

    weierophinney committed May 9, 2012
    - If fieldset implements InputFilterProvider
      - do nothing if input filter already has an input/filter for that
        fieldset
      - otherwise, create an input filter from the provided spec and attach
        it to the form input filter with the fieldset name
    - If fieldset does not implement InputFilterProvider
      - if there is no input/filter for the fieldset, do nothing
      - if the input for the fieldset is not an input filter, do nothing
      - otherwise, attempt to attach defaults for the elements of the
        fieldset to the input filter for this fieldset
  66. @weierophinney

    [zen-12] Completed tests for input filter seeding

    weierophinney committed May 10, 2012
    - will use input specification from element in input filter if no
      matching input found
    - will use input filter specification from fieldset in input filter if
      no matching input filter found
    - will populate sub-input filter from input specifications on fieldset
      elements
  67. @weierophinney
  68. @weierophinney

    [zen-12] Moved Hydrator from Form to Stdlib component

    weierophinney committed May 10, 2012
    - Not necessarily specific to forms
  69. @weierophinney

    [zen-12] Completed Captcha element

    weierophinney committed May 10, 2012
    - Added InputProviderInterface implementation
      - adds StringTrim filter
      - marks as required
      - adds captcha as validator, if present
  70. @weierophinney

    [zen-12] Created CSRF element

    weierophinney committed May 10, 2012
    - Implements InputProviderInterface, attaching its validator
    - Uses CSRF validator's hash as value
  71. @weierophinney
  72. @weierophinney

    [zen-12] Created generic FormElement view helper

    weierophinney committed May 10, 2012
    - introspects element to determine which view helper to delegate
      rendering to.
  73. @weierophinney

    [zen-12][ZF2-290] Modified tests

    weierophinney committed May 10, 2012
    - Verify that disabled does not appear anywhere in the markup
      - Also verify this when no disabled attribute is provided at all
  74. @weierophinney

    [zen-12] Bi-directional bind support

    weierophinney committed May 10, 2012
    - HydratorInterface now defines extract($object), expecting it to return
      an array of data
    - BaseForm::bind() now extracts data from the object and uses it to
      populateValues()
    - todo: use bound data as data for validation if setData() has not been
      called
  75. @weierophinney

    [zen-12] Completed bind() bi-directional support

    weierophinney committed May 10, 2012
    - If setData() has not been called, but bind() has, use the data from
      the bound model in validations
  76. @weierophinney

    [zen-12] Fixes based on functional testing

    weierophinney committed May 10, 2012
    - BaseForm should set $filter to the object's filter, instead of just returning
      it; ensures Form is using the same instance
    - Typehint on ValidatorInterface in InputFilter factory, not Validator
  77. @weierophinney

    [zen-12] allow using populate()

    weierophinney committed May 10, 2012
    - Allows it to work with Zend\Db row population
  78. @weierophinney

    Remove debug code...

    weierophinney committed May 10, 2012
  79. @weierophinney

    [zen-12] added prepare() to Form implementation

    weierophinney committed May 10, 2012
    - Ensures that any automated scanning that needs to be done is complete;
      currently, this simply means that any scanning for default input is
      performed (thus ensuring validators are attached -- which may be
      necessary for elements like the csrf and captcha elements).
  80. @weierophinney

    [zen-12] Removed InputFilterAwareInterface from FormInterface

    weierophinney committed May 10, 2012
    - Instead, define setter/getter for InputFilter (fixes issues with DI)
  81. @weierophinney

    [zen-12] Working CSRF element

    weierophinney committed May 10, 2012
    - Use session hash to validate
    - Do not initialize CSRF token and session until element value attribute is
      retrieved (either via getAttribute('value') or getAttributes()) -- typically,
      this will only happen when rendering.
  82. @weierophinney

    [zen-12] Fixes to Captchas

    weierophinney committed May 10, 2012
    - removed constructor from AbstractAdapter -- let it inherit from
      AbstractValidator to ensure the messages and other information are correctly
      marshalled
  83. @weierophinney

    [zen-12] Rename InputFilter to BaseInputFilter

    weierophinney committed May 10, 2012
    - in preparation for a factory-based input filter implementation
  84. @weierophinney

    [zen-12] Created factory-backed InputFilter implementation

    weierophinney committed May 10, 2012
    - Composes Factory (lazily, or explicitly)
    - add() will create an input using the spec given before passing on to parent
      implementation
  85. @weierophinney

    [zen-12] Remove old test

    weierophinney committed May 11, 2012
    - Removed test for render() method of Dumb captcha adapter; render is no
      longer part of the interface or implementation
  86. @weierophinney

    [zen-12] Removed Dojo from test suite

    weierophinney committed May 11, 2012
    - Dojo integration largely relied on integration with Zend\Form; removing from
      testing for now, as it has not been refactored to work with the new Zend\Form
      code.
  87. @weierophinney

    [zen-12] Fix test asset

    weierophinney committed May 11, 2012
    - Test asset was not in sync with Zend\Session\ManagerInterface
  88. @weierophinney

    [zen-12] Removed FormCsrf view helper

    weierophinney committed May 11, 2012
    - Depended on old Zend\Form code
  89. @weierophinney

    [zen-12] Added test for checked status

    weierophinney committed May 11, 2012
    - Added a test to ensure no checked attribute is rendered if no radios
      are selected
  90. @weierophinney

    [zen-12] Fix 5.4 related issue

    weierophinney committed May 11, 2012
    - Was checking against a key that may not exist; use pre-initialized
      $value instead (more appropriate anyways)
  91. @weierophinney
  92. @weierophinney
  93. @weierophinney

    [zen-12] Inject not-empty validator in input

    weierophinney committed May 11, 2012
    - Injected if required or allow_empty is false; prepended to validator
      chain
Commits on May 14, 2012
  1. @weierophinney

    [ZF2-299] allow combining callback options and context

    weierophinney committed May 14, 2012
    - If we have $context, it should appear immediately following the $value
      when passed to the callback.
Commits on May 15, 2012
  1. @weierophinney

    [zen-12] Fixes issue with duplicated IDs

    weierophinney committed May 15, 2012
    - Do not generate id by default, except for form
    - If "id" attribute is present in a radio or multi-checkbox, only render
      it for the first in the set
  2. @weierophinney

    [zen-12] Fixed select rendering

    weierophinney committed May 15, 2012
    - Allow options of key/value pairs in FormSelect
  3. @weierophinney
  4. @weierophinney

    [zen-12] MultiCheckbox names should append []

    weierophinney committed May 15, 2012
    - in order to denote array value
  5. @weierophinney

    [zen-12] Fixes captcha element rendering and validation

    weierophinney committed May 15, 2012
    - StringTrim no longer attempts to filter non-string values
    - word-based captchas now ensure that the id input has the value set to
      the captcha ID
    - word-based captchas do not attempt to render the input
  6. @weierophinney

    [zen-12] BIND_ON_VALIDATE and bindValues()

    weierophinney committed May 15, 2012
    - Created new method, bindValues(); used to bind values to the bound
      object. It takes the place of hydrate(), and is public. It will fail
      if the form is in an invalid state.
    - New flag, bindOnValidate, with two states: BIND_ON_VALIDATE and
      BIND_MANUAL. By default, the former is true, meaning that during
      isValid(), if validation is successful, bindValues() will be called.
      If the flag is set to BIND_MANUAL, you will need to call bindValues()
      yourself.
  7. @weierophinney

    [zen-12] Ensure ID is rendered once for radio, multi-checkbox

    weierophinney committed May 15, 2012
    - Ensures ID is rendered exactly once for radio and multi-checkbox
      elements, when present