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

  • Home
  • SEARCH
  • 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 8007249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:45:58+00:00 2026-06-04T17:45:58+00:00

Right now I’m trying to write a function that would allow me to access

  • 0

Right now I’m trying to write a function that would allow me to access member functions. The code in question looks a little like this:

protected $formName;
protected $formClass;
protected $formAction;
protected $formMethod;
protected $formObjArray = array(); //outputs in order. So far it should only take newLine, selectTag, inputTag, textTag.
protected $submitBtnVal;
protected $encType;

function __construct($args) {
  $this->formName = $args['formName'];
  $this->formAction = $args['formAction'];

  if (isset($args['formClass'])) $this->formClass = $args['formClass'];
  if (isset($args['encType'])) $this->encType = $args['encType'];

  //default should be POST. Hell, you should never really be using GET for this..
  //also, the default submit value is Submit
  $this->formMethod = isset($args['formMethod']) ? $args['formMethod'] : "POST"; 
  $this->submitBtnVal = isset($args['submitBtnVal']) ? $args['submitBtnVal'] : "Submit";
}

//get functions
function getFormName () { return $this->formName; }
function getFormAction () { return $this->formAction; }
function getFormMethod () { return $this->formMethod; }
function getSubmitBtnVal () { return $this->submitBtnVal; }
function getEncType () { return $this->encType; }

//set functions
function setFormName ($newName) { $this->fromName = $newName; }
function setFormAction ($newAction) { $this->formAction = $newAction; }
function setFormMethod ($newMethod) { $this->formMethod = $newMethod; }
function setEncType ($newEType) { $this->encType = $newEType; }

function addTag($newTag) {
  if ($newTag instanceof formTag || $newTag instanceof fieldSetCont || $newTag instanceof newLine
      || $newTag instanceof noteTag)
    $this->formObjArray[] = $newTag;
  else throw new Exception ("You did not add a compatible tag.");
}

I’d like to be able to call $myForm->getTagByName("nameA")->setRequired(true);

How would I do that? Or would I need to do something more like..

$tagID = $myForm->getTagByName("nameA");
$myForm->tagArray(tagID)->setRequired(true);
  • 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-06-04T17:45:59+00:00Added an answer on June 4, 2026 at 5:45 pm

    Nothing in your code seems to be protected so you should have no trouble accessing any of it.

    It looks like all your tags are in $formObjArray so it should be trivial to filter than array and return tags that match the name you’ve passed in. The trouble you will have is that, getTagByName really should be getTagsByName and should return an array because you can have more than one tag with the same name. Since it will return an array, you can not call setRequired on the return value, arrays don’t have such a method. You’ll need to do it more like:

    $tags = $myForm->getTagsByName("nameA");
    foreach ($tags as $tag) {
        $tag->setRequired(true);
    }
    

    Exactly what are you stuck on? Maybe I don’t understand the question very well.

    So maybe the filtering has you stuck? Try this (if you you’re using at least php 5.3)

    function getTagsByName($tagname) 
    {
        return array_filter($this->formObjArray, function($tag) use($tagname) { 
            return $tag->getName() == $tagname; 
        });
    }
    

    No ifs or switches.

    Prior to 5.3, you don’t have lambda functions so you need to do it differently. There are several options but this may be the simplest to understand:

    function getTagsByName($tagname) 
    {
        $out = array();
        foreach ($this->formObjArray as &$tag) {
            if ($tag->getName() == $tagname) {
                $out[] = $tag;
            }
        }
        return $out;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, I have code that looks something like this: Private Sub ShowReport(ByVal reportName
Right now the code below looks for the author_id and the target_object_id in the
Right now I have a function, in a class that is used to listen
right now i have this <script type='text/javascript'> $(#beau).click(function(){ $(#beau).animate({margin-Top: 738px}, fast); }); </script> and
Right now I have an application that loads a bunch of thumbnail images into
Right now, I have basic code for moving the textfield above the keyboard when
Right now I've programmed a method for use in a swing program that is
Right now, I only understand that Global indexes on a partitioned table are for
Right now I am writing some Python code to deal with massive twitter files.
Right now, I have developed an android app that is available free on the

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.