Skip to content
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

Foreign key field rendered as select, even if it is declared as text #158

Open
pildit opened this issue May 5, 2020 · 0 comments
Open

Comments

@pildit
Copy link

pildit commented May 5, 2020

Before you submit an issue please read this

This repository is only for reporting bugs or issues. If you need support, please use Stack Overflow using laravel-code-generator tag (https://stackoverflow.com/questions/tagged/laravel-code-generator)

Please provide us with details by completing the following requirements. Issues with not enough info are likely to be closed without resolution.

Environment:

  • Laravel-Code-Generator Version: 2.4.4
  • Laravel Version: 7.7.1

Description:

I have a field called product_id in my JSON resource file, it is defined as a foreign key , ref to Product.id key. I declared it as
"html-type": "text",

but when i generate a create view, it is rendered as a <select> field.

Now, if i set "foreign-relation" to null, the field is rendered correctly.

Is this a bug or am I missing something ?
The thing is i would like to be able to render it as text, but keep the foreign-relation also.

Steps/Commands To Reproduce:

php artisan create:create-view Review --force

Content Of The Resource-File:

{
            "name": "product_id",
            "labels": "Product",
            "html-type": "text",
            "css-class": "",
            "options": {},
            "html-value": null,
            "validation": "",
            "is-on-index": true,
            "is-on-show": true,
            "is-on-form": true,
            "data-type": "int",
            "data-type-params": [],
            "data-value": null,
            "is-index": true,
            "is-unique": false,
            "is-primary": false,
            "comment": null,
            "is-nullable": true,
            "is-header": false,
            "is-unsigned": true,
            "is-auto-increment": false,
            "is-inline-options": false,
            "is-date": false,
            "date-format": "",
            "cast-as": "",
            "placeholder": "Select product",
            "delimiter": "; ",
            "range": [],
            "foreign-relation": {
                "name": "product",
                "type": "belongsTo",
                "params": [
                    "App\\Models\\Product",
                    "product_id"
                ],
                "field": "id"
            },
            "foreign-constraint": null,
            "on-store": null,
            "on-update": null,
            "api-key": "product_id",
            "is-api-visible": true,
            "api-description": "The product of the model."
        },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant