-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BelongsTo relation in BREAD form has different form name than the generated name in VoyagerBaseController #3428
Comments
MrCrayon
added a commit
to MrCrayon/voyager
that referenced
this issue
Feb 1, 2020
In a belongsTo relationship both fields: relationship and foreign key play a role but this is not explained in docs. Closes thedevdojo#3428
MrCrayon
added a commit
to MrCrayon/voyager
that referenced
this issue
Feb 1, 2020
In a belongsTo relationship both fields: relationship and foreign key play a role but this is not explained in docs. Closes thedevdojo#3428
MrCrayon
added a commit
to MrCrayon/voyager
that referenced
this issue
Mar 24, 2020
In a belongsTo relationship both fields: relationship and foreign key play a role but this is not explained in docs. Closes thedevdojo#3428
emptynick
added a commit
that referenced
this issue
Jan 29, 2021
In a belongsTo relationship both fields: relationship and foreign key play a role but this is not explained in docs. Closes #3428 Co-authored-by: Christoph Schweppe <[email protected]>
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version information
Description
When I want to save a new entry of a model with a BelongsTo relationship, I get an SQL error that the foreign key is not included in the INSERT query and that no default value for the foreign key is set:
SQLSTATE[HY000]: General error: 1364 Field 'faq_category_id' doesn't have a default value (SQL: insert into `frequently_asked_questions` (`question`, `answer`, `updated_at`, `created_at`) values (ksdjkdj, <p>skdjlsjdjskl ;kjsdldksdjklsjdkljs</p>, 2018-07-30 18:36:38, 2018-07-30 18:36:38))
This is something that happened after I upgraded from Voyager 1.1.2 to 1.1.3. I did not change anything on my BREAD. I removed the relationship once and then reset it but the same occurs again.
I have been debugging this a bit and found out the following. When a model has a BelongsTo relationship, it appears my blade view generates a different name for the field in the BREAD form than the VoyagerBaseController expects. For example, in the BREAD form and hence also in the request, the field name for the foreign key is faq_category_id (which is also the column name in the database table). However the
$row->field
variable in the functioninsertUpdateData
has the valuefrequently_asked_question_belongsto_faq_category_relationship
. I am wondering where the difference comes from. Could anyone shed some light on this? Thank you very much!Could it be related to the Voyager upgrade from 1.1.1 to 1.1.2 to 1.1.3 that my project went through? Do some new assets or views need to be published? Or some command run? I check the installation command but it does much more than what I need (e.g. run database migrations).
The text was updated successfully, but these errors were encountered: