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 7194785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:26:39+00:00 2026-05-28T20:26:39+00:00

I have the following php script now i want to put his script in

  • 0

I have the following php script now i want to put his script in zend forms Here is my code so far :-

$parents = array();
$childs = array();
foreach ($this->Tagkey as $aResultDataValue) {
        $parents [$aResultDataValue['parent']] = $aResultDataValue['parent'];
        $childs [$aResultDataValue['parent']][] = $aResultDataValue['child'];
}

foreach ($parents as $parent) {
     echo '<div>';
     $parent_value = "'$parent'";
     echo '<div><input type="checkbox" name="parents[]" value="'.$parent.'" id="'.$parent.'" class="parentCheck"/>
     <label for="parents_'.$parent.'">'.$parent.'</label></div>';
         foreach ($childs[$parent] as $child) {
           $child_value = "'$child'";
               echo '<div style="margin-left:15px;"><input type="checkbox" name="childs[]" value="'.$child.'" id="childs_'.$child.'" class="child_'.$parent.'" onclick="checkParent('.$parent_value.','.$child_value.');"/>
              <label for="childs_'.$child.'">'.$child.'</label></div>';
     }
     echo '</div>';
} 

now i am going to use this pure php script in zend form what i am trying is here :-

class Admin_Form_Users extends Zend_Form
{

public function init()
{   

   $parents = array();
      $childs = array();

      foreach ($this->Tagkey as $result) {
        $parents [$result['parent']] = $result['parent'];
        $childs [$result['parent']][] = $result['child'];
        }

       foreach ($parents as $parent) {

       $subForm = new Zend_SubForm();
       $subForm->addElement($parent);

       foreach ($children as $child) {
           $subForm->addElement($child);
       }

       $form->addSubForm($subForm);
    }      


        $parent = new Zend_Form_SubForm();
        $parent->addElements(array(
            new Zend_Form_Element_MultiCheckbox('subscriptions', array(
                'label'        =>
                    'Which parent would you like to subscribe to?',
                'multiOptions' => $parents,
                'required'     => true,
                'filters'      => array('StringTrim'),
                'validators'   => array(
                    array('InArray',
                          false,
                          array(array_keys($parents)))
                )
            )),
        ));

        $child = new Zend_Form_SubForm();
        $child->addElements(array(
            new Zend_Form_Element_MultiCheckbox('subscriptions', array(
                'label'        =>
                    'Which child would you like to subscribe to?',
                'multiOptions' => $childs,
                'required'     => true,
                'filters'      => array('StringTrim'),
                'validators'   => array(
                    array('InArray',
                          false,
                          array(array_keys($childs)))
                )
            )),
        ));


         $this->addSubForms(array(

        '$child' => $child,
        'parent' => $parent
    ));

I got an error

Warning: Invalid argument supplied for foreach() in /var/www/dashboard_campaign/application/modules/admin/forms/Users.php on line 19

means here :- foreach ($this->Tagkey as $aResultDataValue) {

Tagkey comes from database model

what i can do an I am newbie in zend framework what i am doing wrong help me

  • 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-28T20:26:40+00:00Added an answer on May 28, 2026 at 8:26 pm

    $TagKey is not a member of Zend_Form, and I don’t see where it is being added to it.

    You could either pass the model that TagKey comes from into the form’s constructor, or in the form’s init() method, you need to create an instance of the model and get the TagKey variable.

    Here is how you can get it from your controller into the form object.

    public function editAction()
    {
        $tags = new Campaign_Model_DbTable_Tag();
        $aResultData = $tags->getTagkey();
        $this->view->Tagkey = $aResultData;
    
        $form = new Admin_Form_Users($aResultData);
    
        if ($this->getRequest()->isPost()) {
            if ($form->isValid($this->getRequest()->getPost())) {
                // valid
            } else { 
                // errors 
            }
        }
    }
    

    Then add a constructor to your form.

    // Admin_Form_Model
    public function __construct($tagKey)
    {   
        $this->tagKey = $tagKey;
    
        parent::__construct(); // you must call this last as it calls init()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following php script now i want to put his script in
I have the following PHP-script, now I need to do the same thing in
I have the following PHP script: <?php $fortune = `fortune`; echo $fortune; ?> but
I have the following situation. I have a PHP script that imports a CSV
I have a PHP script that does the following: Uses file_get_contents() to get content
i have the following simple script <input class=input type=text name=password style=color: #797272; value= <?php
I have a directory structure like the following; script.php inc/include1.php inc/include2.php objects/object1.php objects/object2.php soap/soap.php
I have following PHP code $val=<div id=user.$row['cid']. userid=.$row['cid']. class=innertxt><img src=images/images.jpg width=50 height=50><strong>.$uname.</strong><ul> <li>Email: .$row['cemail'].</li>
I have the following php code, which has been snipped for brevity. I am
I have the following PHP code which works out the possible combinations from a

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.