Comments (4)
Hi Vincent,
Thank you, I appreciate a lot and I'm glad you like it!
Could you please help me by sending the exact code (with any dependencies it might rely on: migrations, models, etc.) which produces this error?
from laraform.
Thanks for the quick reply!
I just whipped up a test form for this specific error with just two fields, so I could single out the problem. The form has been created using the backend rendering method.
App\Forms\TestForm.php
<?php
namespace App\Forms;
use Laraform;
class TestForm extends Laraform
{
public $endpoint = '/laraform/process';
public $model = \App\TestForm::class;
public $schema = [
'name' => [
'type' => 'text',
'label' => 'Name',
'rules' => 'required'
],
'photo' => [
'type' => 'image',
'label' => 'Photo',
'rules' => 'nullable'
]
];
public $buttons = [
0 => [
'label' => 'Submit',
'class' => 'btn-primary'
]
];
}
App\TestForm.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class TestForm extends Model
{
protected $fillable = ['name', 'photo'];
}
The migration
public function up()
{
Schema::create('test_forms', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('photo')->nullable();
$table->timestamps();
});
}
The frontend uses the default laraform
component. Also files like filesystems.php
are unchanged in this example. The error is still there, but like I wrote, the actual file is uploaded succesfully to the local disk. It just won't persist to the database.
Let me know if you'd need any more info!
from laraform.
Thank you for the detailed example! I've managed to look into it and realized that the documentation wasn't clear about that you must have an id
element (or the equivalent primary key) when using files. This is because files are only processed after all the data is saved and they get updated, which makes possible custom store functions, etc.
So the only thing you need to do is to update your schema like:
App\Forms\TestForm.php
<?php
namespace App\Forms;
use Laraform;
class TestForm extends Laraform
{
public $endpoint = '/laraform/process';
public $model = \App\TestForm::class;
public $schema = [
'id' => [
'type' => 'key',
],
'name' => [
'type' => 'text',
'label' => 'Name',
'rules' => 'required'
],
'photo' => [
'type' => 'image',
'label' => 'Photo',
'rules' => 'nullable'
]
];
public $buttons = [
0 => [
'label' => 'Submit',
'class' => 'btn-primary'
]
];
}
from laraform.
That does the trick, thanks a lot for your help!
from laraform.
Related Issues (20)
- If the submit button is clicked in a form, how can it automatically scroll to the first validation error if an error exists HOT 3
- [BUG] validation rule "before" and "before_or_equal" for date elements not working as expected HOT 2
- [QUESTION] is Possible to Drag n Drop component like google form? HOT 3
- [BUG] validation is not running on "onInput" event for TextElement (inputType="number") HOT 2
- [QUESTION] Planned support for Tailwind CSS? HOT 4
- [QUESTION] Does full version comes with uncompress version of JS code ? HOT 4
- [BUG] Trouble initiating laraform with laravel-pug (pugjs) HOT 4
- Support !!! [BUG] HOT 5
- [BUG] storing files in related model using AutoProcess and Wizard HOT 2
- [QUESTION] Custom schema for edit HOT 3
- [QUESTION] Hide Radio Group items HOT 2
- [BUG] PHP 8.1: HasMany::hasKey throws error HOT 6
- [BUG] PHP8.1/L9: HasMany::update fails if model has appended attributes HOT 4
- [BUG] AlgoliaSearchError HOT 4
- [BUG] Regexp mask for text inputs from backend HOT 4
- Maintenance Mode / Laraform Future / Vue.js 3 HOT 2
- Client-Side Storage HOT 2
- [BUG] Class "Route" not found (Laravel)
- [BUG] Form not showing after install HOT 4
- [QUESTION] Ignore data on submit HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laraform.