open-admin-org / open-admin

open-admin forked from z-song/laravel-ladmin. Removing jquery, now based on Bootstrap5, vanilla JS
https://open-admin.org
MIT License
249 stars 71 forks source link

Ignored fields are still processed when updating (not sure when storing, but I guess so) #121

Open stebogit opened 10 months ago

stebogit commented 10 months ago

Describe the bug Ignored fields are not ignored in Form::prepareUpdate

To Reproduce

protected function form(): Form
{
    $form = new Form(new Model());

    $form->text('contact_id', 'Contact ID')->disabled();
    $form->text('field_to_ignore', 'Field');

    // ...

    $form->submitted(function(Form $form) {
        if ($scheduled_at = $form->input('field_to_ignore')) {
            // do stuff
        }

        $form->ignore('field_to_ignore');
        // THIS BREAKS:
        // Column not found: 1054 Unknown column 'field_to_ignore' in 'field list' (SQL: update ...
    });

    return $form;
}

Expected behavior I assumed I could add a field to the form that I can process separately and not have to match any model attribute

System

RCyrix commented 9 months ago

Hi there,

I'm not to sure this helps

I'm on

OS : Ubuntu 21 Database : PostgreSQL 15, Underlying framework : Laravel 10 Open admin : 1.0.27

Tried in

Firefox Chrome

I do not have this issue,

I am able to ignore without a problem, i have just tested now and confirmed on varchar() and integer type values

RCyrix commented 8 months ago

Describe the bug Ignored fields are not ignored in Form::prepareUpdate

To Reproduce

protected function form(): Form
{
    $form = new Form(new Model());

    $form->text('contact_id', 'Contact ID')->disabled();
    $form->text('field_to_ignore', 'Field');

    // ...

    $form->submitted(function(Form $form) {
        if ($scheduled_at = $form->input('field_to_ignore')) {
            // do stuff
        }

        $form->ignore('field_to_ignore');
        // THIS BREAKS:
        // Column not found: 1054 Unknown column 'field_to_ignore' in 'field list' (SQL: update ...
    });

    return $form;
}

Expected behavior I assumed I could add a field to the form that I can process separately and not have to match any model attribute

System

* Open-admin version **1.0.27**

* PHP version **7.4**

* Laravel Version **8**

* OS: **Mac**

* Browser **Brave, Chrome**

if ($scheduled_at = $form->input('field_to_ignore')) { // do stuff }

    Just going over old tickets etc, 

    is that  correct?
    if ($scheuled_at = $form->input('field_to_ignore')){

    }

    It's only a single = 

    So it wouldnt check equality but would attempt assignment?

wondering if its not affecting the submission hook... also is the field available in the form inputs of the submission hook? if you dump out the form inputs, are you able to see the value you want the function to act on?

Kind regards