open-admin
open-admin copied to clipboard
Ignored fields are still processed when updating (not sure when storing, but I guess so)
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
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
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