Formal\Form::setModelInstance PHP Method

setModelInstance() public method

public setModelInstance ( $oModelInstance )
    function setModelInstance($oModelInstance)
    {
        if (!\Flake\Util\Tools::is_a($oModelInstance, $this->sModelClass)) {
            throw new \Exception("\\Formal\\Core->setModelInstance(): Given instance is not of class '" . $this->sModelClass . "'");
        }
        $this->oModelInstance = $oModelInstance;
        $this->oElements->reset();
        foreach ($this->oElements as $oElement) {
            $oElement->setValue($this->modelInstance()->get($oElement->option("prop")));
        }
        # Displayed form title is generated depending on modelInstance floatingness
        if ($this->floatingModelInstance()) {
            $this->sDisplayTitle = "Creating new<i class=" . $this->modelInstance()->mediumicon() . "></i><strong>" . $this->modelInstance()->humanName() . "</strong>";
        } else {
            # This is changed if form is persisted, after persistance, to reflect possible change in model instance label
            $this->sDisplayTitle = "Editing " . $this->modelInstance()->humanName() . "<i class=" . $this->modelInstance()->mediumicon() . "></i><strong>" . $this->modelInstance()->label() . "</strong>";
        }
        return $this;
    }