Skip to content

Action Executor ignores field value for the preview function #969

@romaninsh

Description

@romaninsh

When action defines fields=['name'] - executor asks for that name and sets it before executing action (as expected)

If you have a preview, however, the value is not set for the preview:

Screenshot 2020-02-26 at 18 44 24

Screenshot 2020-02-26 at 18 44 28

Screenshot 2020-02-26 at 18 44 37

Screenshot 2020-02-26 at 18 44 41

Screenshot 2020-02-26 at 18 44 45

Code:


class Client extends Model
{
    public $table = 'client';

    public function init()
    {
        parent::init();

        $this->addField('name');

        $this->addAction('send_statement', [ 'fields'=>['name'], 'preview'=>'send_statement_preview']);
    }

    public function send_statement_preview() {
        return 'here goes your statement '.$this['name'];

    }
    public function send_statement() {
        /*
        if (!isset($this->app->mailer)) {
            throw new ValidationException('ouch');
        }
        */
        return 'sent to '.$this['name'];
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions