コード例 #1
0
 /**
  * Render list item
  *
  * @param string $relationId   The relationship identity
  * @param BaseModel $item      Record object.
  * @return Element('li')
  */
 public function renderItem($relationId, $subset, $item, $on = false)
 {
     $id = $item->id;
     $li = new Element('li');
     $label = new Label();
     $hiddenId = new HiddenInput("{$relationId}[{$id}][_foreign_id]", array('value' => $id));
     $checkboxValue = $on ? 1 : 0;
     $checkbox = new CheckboxInput("{$relationId}[{$id}][_connect]", array('value' => $checkboxValue));
     if ($on) {
         $checkbox->check();
     }
     $label->append($checkbox);
     $label->append($item->dataLabel());
     $label->append($hiddenId);
     $li->append($label);
     return $li;
 }
コード例 #2
0
ファイル: StackView.php プロジェクト: corneltek/actionkit
 /**
  * For each existing (one-many) records, 
  * create it's own subaction view for these existing 
  * records.
  */
 public function buildOneToManyRelationalActionViewForExistingRecords($record, $relationId, $relation = null)
 {
     if (!$relation) {
         $relation = $this->action->getRelation($relationId);
     }
     $container = new Element('div');
     // If the record is loaded and the relation is defined
     if ($collection = $record->fetchOneToManyRelationCollection($relationId)) {
         foreach ($collection as $subrecord) {
             $subview = $this->createRelationalActionView($relationId, $relation, $subrecord);
             $container->append($subview);
         }
     }
     return $container;
 }