original_string: private function linkToLevelAbove(&$top, $elements, $inGroup = false)
      {
          $key = $this->options['key_id'] ? 'id' : 'name';
  
          foreach($elements as &$elem) {
              $top_key = $elem[$key];
  
              // If in a group, convert something like inGrp[F4grp][F4_1] to F4_1
              // Don't do if key_id as the value is a straight id.
              if( !$this->options['key_id'] && $inGroup && $top_key != '') {
                  if(!(preg_match("/\[?([\w_]+)\]?$/i", $top_key, $match)))
                      throw new HTML_QuickForm2_InvalidArgumentException(
                          "linkToLevelAbove can't obtain the name from '$top_key'");
                  $top_key = $match[1];
              }
  
              // Radio buttons: several elements with the same name, make an array
              if(isset($elem['type']) && $elem['type'] == 'radio') {
                  if( ! isset($top[$top_key]))
                      $top[$top_key] = array('id' => $top_key, 'type' => 'radio', 'elements' => array(0));
                  $top[$top_key][$elem['id']] = &$elem;
              } else    // Normal field, just link into the level above.
                  if( ! isset($top[$top_key]))
                      $top[$top_key] = &$elem;    // Link into the level above
  
              // If we have a group link its fields up to this level:
              if(isset($elem['elements']['0']))
                  $this->linkToLevelAbove($elem, $elem['elements'], true);
  
              // Link errors to the top level:
              if(isset($elem['error']) && isset($this->array[$elem['error']]))
                  $this->array['errors'][$top_key] = $this->array[$elem['error']];
          }
      }
code: private function linkToLevelAbove(&$top, $elements, $inGroup = false)
      {
          $key = $this->options['key_id'] ? 'id' : 'name';
  
          foreach($elements as &$elem) {
              $top_key = $elem[$key];
  
              // If in a group, convert something like inGrp[F4grp][F4_1] to F4_1
              // Don't do if key_id as the value is a straight id.
              if( !$this->options['key_id'] && $inGroup && $top_key != '') {
                  if(!(preg_match("/\[?([\w_]+)\]?$/i", $top_key, $match)))
                      throw new HTML_QuickForm2_InvalidArgumentException(
                          "linkToLevelAbove can't obtain the name from '$top_key'");
                  $top_key = $match[1];
              }
  
              // Radio buttons: several elements with the same name, make an array
              if(isset($elem['type']) && $elem['type'] == 'radio') {
                  if( ! isset($top[$top_key]))
                      $top[$top_key] = array('id' => $top_key, 'type' => 'radio', 'elements' => array(0));
                  $top[$top_key][$elem['id']] = &$elem;
              } else    // Normal field, just link into the level above.
                  if( ! isset($top[$top_key]))
                      $top[$top_key] = &$elem;    // Link into the level above
  
              // If we have a group link its fields up to this level:
              if(isset($elem['elements']['0']))
                  $this->linkToLevelAbove($elem, $elem['elements'], true);
  
              // Link errors to the top level:
              if(isset($elem['error']) && isset($this->array[$elem['error']]))
                  $this->array['errors'][$top_key] = $this->array[$elem['error']];
          }
      }
code_tokens: private function linkToLevelAbove ( & $ top , $ elements , $ inGroup = false ) { $ key = $ this -> options [ 'key_id' ] ? 'id' : 'name' ; foreach ( $ elements as & $ elem ) { $ top_key = $ elem [ $ key ] ; // If in a group, convert something like inGrp[F4grp][F4_1] to F4_1 // Don't do if key_id as the value is a straight id. if ( ! $ this -> options [ 'key_id' ] && $ inGroup && $ top_key != '' ) { if ( ! ( preg_match ( "/\[?([\w_]+)\]?$/i" , $ top_key , $ match ) ) ) throw new HTML_QuickForm2_InvalidArgumentException ( "linkToLevelAbove can't obtain the name from '$top_key'" ) ; $ top_key = $ match [ 1 ] ; } // Radio buttons: several elements with the same name, make an array if ( isset ( $ elem [ 'type' ] ) && $ elem [ 'type' ] == 'radio' ) { if ( ! isset ( $ top [ $ top_key ] ) ) $ top [ $ top_key ] = array ( 'id' => $ top_key , 'type' => 'radio' , 'elements' => array ( 0 ) ) ; $ top [ $ top_key ] [ $ elem [ 'id' ] ] = & $ elem ; } else // Normal field, just link into the level above. if ( ! isset ( $ top [ $ top_key ] ) ) $ top [ $ top_key ] = & $ elem ; // Link into the level above // If we have a group link its fields up to this level: if ( isset ( $ elem [ 'elements' ] [ '0' ] ) ) $ this -> linkToLevelAbove ( $ elem , $ elem [ 'elements' ] , true ) ; // Link errors to the top level: if ( isset ( $ elem [ 'error' ] ) && isset ( $ this -> array [ $ elem [ 'error' ] ] ) ) $ this -> array [ 'errors' ] [ $ top_key ] = $ this -> array [ $ elem [ 'error' ] ] ; } }
docstring: Key is 'name' or 'id'.
docstring_tokens: Key is name or id .