public function addCalculatedField($name, $expression)
    {
        if (!is_array($expression)) {
            $expression = ['expr' => $expression];
        } elseif (isset($expression[0])) {
            $expression['expr'] = $expression[0];
            unset($expression[0]);
        }

        return $this->addField($name, new Field\Callback($expression));
    }
public function addCalculatedField($name, $expression)
    {
        if (!is_array($expression)) {
            $expression = ['expr' => $expression];
        } elseif (isset($expression[0])) {
            $expression['expr'] = $expression[0];
            unset($expression[0]);
        }

        return $this->addField($name, new Field\Callback($expression));
    }
public function addCalculatedField ( $ name , $ expression ) { if ( ! is_array ( $ expression ) ) { $ expression = [ 'expr' => $ expression ] ; } elseif ( isset ( $ expression [ 0 ] ) ) { $ expression [ 'expr' ] = $ expression [ 0 ] ; unset ( $ expression [ 0 ] ) ; } return $ this -> addField ( $ name , new Field \ Callback ( $ expression ) ) ; }
Add expression field which will calculate its value by using callback.

@param string                $name
@param string|array|callable $expression

@throws \atk4\core\Exception

@return Field\Callback
Add expression field which will calculate its value by using callback .