<commit_before><?php

require_once __DIR__ . '/init.php';

$form = \atk4\ui\Form::addTo($app);
$img = $form->addField('img', ['UploadImg', ['defaultSrc' => './images/default.png', 'placeholder' => 'Click to add an image.']]);
$img->cb->appSticky = true;
//$img->set('a_new_token', '<PASSWORD>');
//$img->setThumbnailSrc('./images/logo.png');

$field = $form->addField('file', ['Upload', ['accept' => ['.png', '.jpg']]]);

//$field->set('a_generated_token', '<PASSWORD>');
//$field->set('a_generated_token');

$img->onDelete(function ($fileId) use ($img) {
    $img->clearThumbnail('./images/default.png');

    return new \atk4\ui\jsToast([
        'title'   => 'Delete successfully',
        'message' =>  $fileId.' has been removed',
        'class'   => 'success',
    ]);
});

$img->onUpload(function ($files) use ($form, $img) {
    if ($files === 'error') {
        return $form->error('img', 'Error uploading image.');
    }

    $img->setThumbnailSrc('./images/logo.png');
    $img->set('123456', $files['name'] . ' (token: 123456)');

    //Do file processing here...

    /* This will get caught by jsCallback and show via modal. */
    //new Blabla();

    /* js Action can be return. */
    //if using form, can return an error to form field directly.
    //return $form->error('file', 'Unable to upload file.');

    // can also return a notifier.
    return new \atk4\ui\jsToast([
                                    'title'   => 'Upload success',
                                    'message' => 'Image is uploaded!',
                                    'class'   => 'success',
                                ]);
});

$field->onDelete(function ($fileId) {
    return new \atk4\ui\jsToast([
        'title'   => 'Delete successfully',
        'message' => $fileId.' has been removed',
        'class'   => 'success',
    ]);
});<commit_msg>Apply fixes from StyleCI (#1037)<commit_after><?php

require_once __DIR__ . '/init.php';

$form = \atk4\ui\Form::addTo($app);
$img = $form->addField('img', ['UploadImg', ['defaultSrc' => './images/default.png', 'placeholder' => 'Click to add an image.']]);
$img->cb->appSticky = true;
//$img->set('a_new_token', '<PASSWORD>');
//$img->setThumbnailSrc('./images/logo.png');

$field = $form->addField('file', ['Upload', ['accept' => ['.png', '.jpg']]]);

//$field->set('a_generated_token', '<PASSWORD>');
//$field->set('a_generated_token');

$img->onDelete(function ($fileId) use ($img) {
    $img->clearThumbnail('./images/default.png');

    return new \atk4\ui\jsToast([
        'title'   => 'Delete successfully',
        'message' =>  $fileId . ' has been removed',
        'class'   => 'success',
    ]);
});

$img->onUpload(function ($files) use ($form, $img) {
    if ($files === 'error') {
        return $form->error('img', 'Error uploading image.');
    }

    $img->setThumbnailSrc('./images/logo.png');
    $img->set('123456', $files['name'] . ' (token: 123456)');

    //Do file processing here...

    /* This will get caught by jsCallback and show via modal. */
    //new Blabla();

    /* js Action can be return. */
    //if using form, can return an error to form field directly.
    //return $form->error('file', 'Unable to upload file.');

    // can also return a notifier.
    return new \atk4\ui\jsToast([
                                    'title'   => 'Upload success',
                                    'message' => 'Image is uploaded!',
                                    'class'   => 'success',
                                ]);
});

$field->onDelete(function ($fileId) {
    return new \atk4\ui\jsToast([
        'title'   => 'Delete successfully',
        'message' => $fileId . ' has been removed',
        'class'   => 'success',
    ]);
});
{'fraction_non_alphanumeric': 0.20975087061344763, 'fraction_numerical': 0.00964371818912403, 'mean_word_length': 2.3914623069936423, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2798555', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1177, 'n_words': 278}