/** * Populate the primary key value from the supplied row (already saved in * the RowEditor) up to the linked field in this object. For example, say * you'd configured a link like this in your RowEditor: * * <pre> * $rowEditor->linkByField('addresses', $this->orderModel->field('address_id')); * </pre> * * Then, when this method was called, you'd get a row from the addresses * table that had already been saved by the row editor. And, using that row, * this method would set the value of the orderModel's address_id field * to the primary key of the addresses row. * * @param Row $row * @return \Dewdrop\Fields\RowEditor\Link\Field */ public function populateValueFromSavedRow(Row $row) { $references = $this->field->getTable()->getMetadata('references'); foreach ($references as $foreignKey => $referencedColumnAndTable) { if ($foreignKey === $this->field->getName()) { $referencedColumn = $referencedColumnAndTable['column']; $this->field->setValue($row[$referencedColumn]); } } return $this; }
/** * Perform a delete using the RowEditor's delete field, if specified. * * @todo Add support for "active" fields as well. * * @return void */ public function delete() { if ($this->hasDeleteField()) { $this->deleteField->setValue(1)->getRow()->save(); } }