laravel-code-generator icon indicating copy to clipboard operation
laravel-code-generator copied to clipboard

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

Open pildit opened this issue 5 years ago • 0 comments

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."
        },

pildit avatar May 05 '20 14:05 pildit