/**
  * Clones element if necessary (if id passed say as "id-1" and it is not found)
  * @return Am_Form_Brick|null
  */
 public function getBrick($class, $id)
 {
     if (!isset($this->bricks[$class][$id]) && isset($this->bricks[$class]) && current($this->bricks[$class])->isMultiple()) {
         if ($id === null) {
             for ($i = 0; $i < 100; $i++) {
                 if (!array_key_exists($class . '-' . $i, $this->bricks[$class])) {
                     $id = $class . '-' . $i;
                     break;
                 }
             }
         }
         $this->bricks[$class][$id] = Am_Form_Brick::createFromRecord(array('class' => $class, 'id' => $id));
     }
     return $this->bricks[$class][$id];
 }
示例#2
0
 /** @return array of Am_Form_Brick */
 function getBricks()
 {
     $ret = array();
     foreach ($this->getFields() as $brickConfig) {
         if (strpos($brickConfig['id'], 'PageSeparator') === 0) {
             continue;
         }
         $b = Am_Form_Brick::createFromRecord($brickConfig);
         if (!$b) {
             continue;
         }
         $ret[] = $b;
     }
     $event = new Am_Event(Am_Event::SAVED_FORM_GET_BRICKS, array('type' => $this->type, 'code' => $this->code, 'savedForm' => $this));
     $event->setReturn($ret);
     $this->getDi()->hook->call($event);
     $ret = $event->getReturn();
     foreach ($ret as $brick) {
         $brick->init();
     }
     return $ret;
 }
示例#3
0
 /** @return array of Am_Form_Brick */
 function getBricks()
 {
     $ret = array();
     foreach ($this->getFields() as $brickConfig) {
         if (strpos($brickConfig['id'], 'PageSeparator') === 0) {
             continue;
         }
         $b = Am_Form_Brick::createFromRecord($brickConfig);
         if (!$b) {
             continue;
         }
         $ret[] = $b;
     }
     return $ret;
 }