Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Getting an error when trying to create a new input field on create ticket #548

Open
Coffeline opened this issue Jan 29, 2020 · 2 comments
Open

Comments

@Coffeline
Copy link

I have a very complicated problem here. I followed the tutorial on the issue #454.

  1. Publish views so you can edit the html layout of the form: php artisan vendor:publish

Publishing the view and adding the new input field was easy, here is what i added:
{!! CollectiveForm::text('address', null, ['class' => 'form-control', 'required' => 'required']) !!}
Capturar2

  1. Create a migration that extends the table ticketit with fields you want.

And on phpmyadmin, i made this:
Capturar
And it has its own index too, just like the "subject" one.

  1. Override TicketsController so that in the store method you can add the functionality to store extra fields. This is how to override a vendor class (read the comments too): https://stackoverflow.com/a/34600074

I created the overrides folder and added the "autoload" thing into composer.json

Now for the problem im having:

When i try to submit the new ticket, i get this error:
SQLSTATE[HY000]: General error: 1364 Field 'address' doesn't have a default value (SQL: insert into ticketit (subject, content, html, priority_id, category_id, status_id, user_id, agent_id, updated_at, created_at) values (TEST SUBJECT, TEST DESC,

TEST DESC

, 1, 1, 1, 1, 1, 2020-01-29 19:01:41, 2020-01-29 19:01:41))

And if i add a default value to "address" on phpmyadmin, or if i make it nullable, it will be an empty field or the default value i set.

Basically, the "address" data is not being sent to the database, and i have no idea why.

@Coffeline
Copy link
Author

By the way, this is what is in my TicketsController's store method:
Capturar

@AhmedAlEssam
Copy link

AhmedAlEssam commented Feb 25, 2020

try to add 'address' to fillable in the ticket model
\kordy\ticketit\src\Models\Ticket.php
like this
protected $fillable = ['address'];

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants