File upload callback in Agile tookit

109 Views Asked by At

I have a agile File input, im using the model File from addons, at the moment without any extend or modifications.

    $f=$this->add('Form');
    $modelo  = $this->add($this->model);

    $f->addField('upload','Upload_test','Upload Test')->setModel($modelo);
    $elemento = $this->add('HtmlElement');

    $t = $this;

    $modelo->addHook('afterSave',function($m) use($t, $elemento)
    {

        $t->js(true)->univ()->alert('Uploaded!');
        $elemento->set('Uploaded');

    });

    $f->onSubmit(function($f) use($t){
        $t->js(true)->univ()->alert(333)->execute();
    });

The callback are triggering but, any modifications to the actual html are failed, also any js like the simple alert saying Uploaded. How can I execute some PHP like $elemento->set('Uploaded'); to inform of the recently uploaded file? The JS with the alert also doesnt work :(

Any help would be apreciated

1

There are 1 best solutions below

1
On

The upload element will have an event "upload" triggered as soon as upload is finished.

https://github.com/atk4/atk4/blob/master/templates/js/ui.atk4_uploader.js#L196

You can fetch data from element's data().