/** * Provide a row that can be linked to all the fields from the supplied * table. If the field has a value, we'll look up the row using the table's * find() method. Otherwise, we'll create a new row. Note that an exception * is throw if you attempt to use this linker with a field that doesn't * itself have a row associated with it already. Often you'll link to the * first row using a \Dewdrop\Fields\RowEditor\Link\QueryString rule and * then string Field linker on after that. * * @throws \Dewdrop\Fields\Exception * @param Table $table * @return \Dewdrop\Db\Row */ public function link(Table $table) { if (!$this->field->hasRow()) { $this->field->setRow($this->rowEditor->getRow($this->field->getGroupName())); } $value = $this->field->getValue(); if ($value) { $row = $table->find($value); } else { $row = $table->createRow(); } return $row; }