This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

maycon.ghizzi34750
maycon.ghizzi34750

hi, after hours searching and trying fixing without success i decided make this post.

Problem: In my update form I create a new button:

myplugin/controllers/achado/update.htm

<a
                data-control="popup"
                data-handler="onFinalize"
                data-load-indicator="Aguarde..."
                href="nojavascript...;"
                class="btn btn-success">
                <span uk-icon="check"></span> Finalizar
            </a>

In myplugin/controllers/Achado.php i have:

 public function __construct()
{
    parent::__construct();
    BackendMenu::setContext('eseti.controladoria', 'main-ci-exec', 'sm-ci-exec2');

    $wmodel = new \eseti\controladoria\Models\AchadoFinalizar;

    $config = $this->makeConfig("$/eseti/controladoria/models/achadofinalizar/fields.yaml");
    $config->model = $wmodel;
    $widget = $this->makeWidget("Backend\Widgets\Form", $config);
    $widget->alias = "Finalizar";
    $widget->form = $wmodel;
    $widget->bindToController();
    $this->vars['widget'] = $widget;

}

public function onFinalize()
{

   return $this->makePartial("popup_create_achadof");
}

public function onFinalizeSave()
{

    $achado_id = $this->params[0];

    $achado = \eseti\controladoria\Models\Achado::find($achado_id);

    $achadoFinalizar = new \eseti\controladoria\Models\AchadoFinalizar();
    $achadoFinalizar->justificativa = post("justificativa");
    $achadoFinalizar->achado = $achado;
    $achadoFinalizar->user = \BackendAuth::getUser();

    try {
        $achadoFinalizar->save();
    } catch (Exception $e) {
        \Flash::danger($e->getMessage());
    }

}

and in my partial _popup_create_achadof.htm i have:

 <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Tem certeza que deseja FINALIZAR este achado?</h4>
</div>
<div class="modal-body">
<?= Form::open(['class' => 'layout', 'files' => true, 'data-request' => "onFinalizeSave"]) ?>

 <div class="layout-row">
    <?= $widget->render() ?>
</div>

<div class="form-buttons">
    <div class="loading-indicator-container">
        <button
                type="submit"
                data-request-data="redirect:1"
                data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"
                class="btn btn-primary">
            <span uk-icon="check"></span> Finalizar
        </button>

        <span class="btn-text">
                <?= e(trans('backend::lang.form.or')) ?> <a href="nojavascript...;" data-dismiss="modal"><?= e(trans('backend::lang.form.cancel')) ?></a>
            </span>
    </div>
</div>
<?= Form::close() ?>
</div>

The popup show correctly:

The problem is the file ulpoad, I can't access the uploaded file, and field upload-file(anexo) not send whith the form in function:

 public function onFinalizeSave()
{

    $achado_id = $this->params[0];

    $achado = \eseti\controladoria\Models\Achado::find($achado_id);

    $achadoFinalizar = new \eseti\controladoria\Models\AchadoFinalizar();
    $achadoFinalizar->justificativa = post("justificativa");
    $achadoFinalizar->achado = $achado;
    $achadoFinalizar->user = \BackendAuth::getUser();

    try {
        $achadoFinalizar->save();
    } catch (Exception $e) {
        \Flash::danger($e->getMessage());
    }

}

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.