how come the lines:

                 echo $form['catcher_id'];

              $catcher_names =  $form['catcher_id']                   
              foreach($catcher_names as $val)
              {
                  echo "testing loop";
              }   

produce nothing?? its not doing the foreach.
$form['catcher_id']; is a dropdown list containing catcher names
please help?
thanks

    print_r($form['catcher_id']); is it what you expect?

      echo $form['catcher_id']

      if i'm not mistaken you have ids in a comma separated list?
      Then you should use explode() to make that list into array first.

      however this works its not the best way to store id numbers, according to the database normalisation forms.

        djjjozsi;10972013 wrote:
        echo $form['catcher_id']

        if i'm not mistaken you have ids in a comma separated list?
        Then you should use explode() to make that list into array first.

        however this works its not the best way to store id numbers, according to the database normalisation forms.

        the line aboce gives me a drop down list and get defined in a base class:

        abstract class BaseLpmServiceForm extends BaseFormPropel
        {
          public function setup()
          {
            $this->setWidgets(array(
              'id'                   => new sfWidgetFormInputHidden(),
              'name'                 => new sfWidgetFormInputText(),
              'wap_home'             => new sfWidgetFormInputText(),
              'call_center_number'   => new sfWidgetFormInputText(),
           [COLOR="Red"]   'catcher_id'           => new sfWidgetFormPropelChoice(array('model' => 'LpmCatcher', 'add_empty' => false)),[/COLOR]
              'price_description'    => new sfWidgetFormInputText(),
              'logo'                 => new sfWidgetFormInputText(),
              'invalid_msisdn_text'  => new sfWidgetFormInputText(),
              'terms_and_conditions' => new sfWidgetFormInputText(),
              'service_code'         => new sfWidgetFormInputText(),
            ));
        
          dagon;10972011 wrote:

          print_r($form['catcher_id']); is it what you expect?

          when i put this line in my code and i run it that particular form then displays nothing...thus errorπŸ˜•

            dagon;10972011 wrote:

            print_r($form['catcher_id']); is it what you expect?

            Dragon, is axactly right. My guess is that $form['catcher_id'] does not contain an array.

            I would do:

            <pre>
            print_r($form['cather_id')
            </pre>
            

            Added <pre> to make it a little easier to read.

              Sops21;10972037 wrote:

              Dragon, is axactly right. My guess is that $form['catcher_id'] does not contain an array.

              I would do:

              <pre>
              print_r($form['cather_id')
              </pre>
              

              Added <pre> to make it a little easier to read.

              yes i see that now thanks, i tried the line:
              echo var_dump($POST($form['catcher_id']));
              and get error
              Fatal error: Function name must be a string in /home/helloises/svn_wappool/apps/lpmanager/modules/adminservice/templates/
              form.php on line 78

              then the line:
              print_r(explode(' ',$form['catcher_id']));
              and got the whole array displayed

              so how can i get the values of my dropdown list in an array so i can access/select them and use the selected value further???

              please help?? i am very new to this and need to learn and doesnt know how all this works yet

              many thanks

                when i echo $val within the for each i get what i wanted:
                Admin AcmeInc FooBar SprintMediaS.L Binbit PlanetTech 2comm ImperialCrown funmobile Froggie zed-catcher MarketByBrand Inmobi FroggieUSCellcom LinguisticMobile MiraTest ContactSMS

                but now: how come it does not recognize the if statement??? check for "zed-catcher"???? it is n the list
                $catcher_names = explode(' ',$form['catcher_id']);

                foreach($catcher_names as $val)
                {
                echo $val;

                if ($val == "zed-catcher ")
                {
                echo $form['service_code']->renderLabel();
                echo $form['service_code']->renderError();
                echo $form['service_code'];
                }
                }

                please help??
                many thanks

                  You have a space before the quote in

                  if ($val == "zed-catcher ")

                  It should be:

                  if ($val == "zed-catcher")
                    Sops21;10972037 wrote:

                    Dragon, is axactly right. My guess is that $form['catcher_id'] does not contain an array.

                    I would do:

                    <pre>
                    print_r($form['cather_id')
                    </pre>
                    

                    Added <pre> to make it a little easier to read.

                    Sops21;10972045 wrote:

                    You have a space before the quote in

                    if ($val == "zed-catcher ")

                    It should be:

                    if ($val == "zed-catcher")

                    thank you took out the space, was just testing, but still not recognizing itπŸ˜•

                      Perhaps there is something wrong with

                      echo $form['service_code']->renderLabel();
                      echo $form['service_code']->renderError();
                      echo $form['service_code'];

                      Have you tried something like:

                      $catcher_names = explode(' ',$form['catcher_id']); 
                      foreach($catcher_names as $val)
                      foreach($catcher_names as $val)
                      {
                      echo $val; 
                      if ($val == "zed-catcher"){
                      echo "Found it";
                      }
                      
                      
                      } 

                        thank you tried ur sugestion...my original code is correct πŸ™‚
                        echo $form['service_code']->renderLabel();
                        echo $form['service_code']->renderError();
                        echo $form['service_code'];

                        still not doing the if πŸ™

                        many thanks...

                          i think i must start looking at java script for this...there is html and the browser involved...any change(new selected value) in the dropdown selection, the page must be refreshed and with the new selected value display my 3 lines..???

                            Write a Reply...