Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a file called formClass.php Your class should have properties to a A list of input. Each entry should be an associative array containing the

Create a file called formClass.php

  1. Your class should have properties to a
    1. A list of input. Each entry should be an associative array containing the keys name, label, type, validation, validationOptions and value. The values for the keys, will be used to generate the input HTML tag
    2. Properties to represent the name of the form, the method and the action
  2. You class should have the following public methods
    1. A constructor that takes in a parameter for the title, method and action
    2. a method called addInput, that takes in the parameter for name, label, type, validation, validaitonOptions and value
      1. name and label do not have default values.
      2. type has a default value of "text".
      3. validation should have a default value of FILTER_DEFAULT
      4. validaitonOptions should have a default value of 0
      5. value should have defdault vaule of an empty string.
      6. Your function should check if the an input with the same name is in the list, and whether type is a valid input type. If the name is not in the list, and the type is a valid input type add the input to the list of inputs.
    3. a method called validateInput that takes in an associative array as a parameter.
      1. The function will validate the KVPs in the array, with keys matching the name of the inputs, using the validation and validationOptions
      2. The function should ignore inputs with names "submit" and "reset", to allows for submit and reset buttons to be added to the form which do not need to be validated.
      3. If all the inputs pass validation, the function should return true
      4. If at least one of the inputs fail validation, return a list names that do not pass validation.
  3. Your class should have the following accessor
    1. html, implemented in the __get method. When the user requets the html property, the html for the form represented by the data in the object properties should be returned.
    2. name, should return the title for the form.
    3. input name, implemented in the __get method. When the user request a property that is a name of an input in the list of inputs, the assocative array describing the input should be returned.

Create a file called formClassUsage.php

  • Using your formClass create a form with fields
    • firstname
    • lastname
    • birthdate
    • haircolor
    • shoesize
    • age
  • Remember to include the submit button in your list of inputs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions