Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3333536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:48:28+00:00 2026-05-17T23:48:28+00:00

I have several classes (for a Form generator class thing I’m making…I know sad..

  • 0

I have several classes (for a Form generator class thing I’m making…I know sad.. 🙁 ),anyway, the hierarchy is as follows:

class HTML_Form accepts abstract class FormElement objects (using type hinting). FormElement class has several children classes such as Textbox, Password, Radio .etc

How would I add validation to these, for example the method I’m trying to make in class HTML_Form is:

$form = new HTML_Form($name);

$form->addElement($type, $name, $validation);

I hope everybody understand… and yes I’m such a noob.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:48:29+00:00Added an answer on May 17, 2026 at 11:48 pm

    If you’re trying to do server side validation, once a POST/GET is received load the form object with the submitted values.

    To your form element classes add a function is_valid(). You can add whatever validations you want there. If you want to use a separate validation function(one that is not element specific but form specific), meaning somebdoy submitted a form that took an reference ID to a database object, and you want to make sure that is the correct object, so your input_text form element would not naturally cover this validation. Add another function to your form_element objects called “set_validation_function”. from there pass in an array of array(class, function). Then update your is_valid() function to check to see if a validation_function is set and if it is use, call_user_function(array(class, function), params) to call the defined function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a Base class and several Derived classes. Is there any
I have a form and several external classes (serial port, file access) that are
If I have interface IFoo, and have several classes that implement it, what is
I have several service classes that have static methods and offer a service to
I have mapped several java classes like Customer, Assessment, Rating, ... to a database
I have a need for methods in several classes that must always follow a
I have a block of code that basically intializes several classes, but they are
I have an ABC with several derived classes. To create these derived classes I
I have been tasked with converting several php classes into java classes, which is
I need to convert several Java classes to C#, but I have faced few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.