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

#29026 [Form] fix: selectForForms issue for manage case where objectdesc don't need to reset #29494

Open
wants to merge 2 commits into
base: 19.0
Choose a base branch
from

Conversation

nicolas-eoxia
Copy link
Contributor

@nicolas-eoxia nicolas-eoxia commented Apr 26, 2024

image

In my case, I'm using the element_element table to add a link to the productlot table

In the code above, you can only link an object that has the link in its table, e.g. fk_productlot or with extrafields. However, these two cases only manage 1 - 1 cardinality, whereas with the element_element table you can manage 1 - N cardinality.

@nicolas-eoxia nicolas-eoxia self-assigned this Apr 26, 2024
@nicolas-eoxia nicolas-eoxia requested a review from eldy April 26, 2024 09:44
@nicolas-eoxia nicolas-eoxia added the Bug This is a bug (something does not work as expected) label Apr 26, 2024
@eldy
Copy link
Member

eldy commented Apr 27, 2024

Strange, you should not need his.
Can you paste the content of the array ->fields in your class Control of module Digiquali ?

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Apr 27, 2024
@nicolas-eoxia
Copy link
Contributor Author

Array
(
[rowid] => Array
(
[type] => integer
[label] => TechnicalID
[enabled] => 1
[position] => 1
[notnull] => 1
[visible] => 0
[showinpwa] => 0
[noteditable] => 1
[index] => 1
[comment] => Id
)

[ref] => Array
    (
        [type] => varchar(128)
        [label] => Ref
        [enabled] => 1
        [position] => 10
        [notnull] => 1
        [visible] => 4
        [showinpwa] => 1
        [noteditable] => 1
        [default] => (PROV)
        [index] => 1
        [searchall] => 1
        [showoncombobox] => 1
        [validate] => 1
        [comment] => Reference of object
    )

[ref_ext] => Array
    (
        [type] => varchar(128)
        [label] => RefExt
        [enabled] => 1
        [position] => 20
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
    )

[entity] => Array
    (
        [type] => integer
        [label] => Entity
        [enabled] => 1
        [position] => 30
        [notnull] => 1
        [visible] => 0
        [showinpwa] => 0
        [index] => 1
    )

[date_creation] => Array
    (
        [type] => datetime
        [label] => DateCreation
        [enabled] => 1
        [position] => 40
        [notnull] => 1
        [visible] => 2
        [showinpwa] => 1
        [positioncard] => 10
    )

[tms] => Array
    (
        [type] => timestamp
        [label] => DateModification
        [enabled] => 1
        [position] => 50
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
    )

[import_key] => Array
    (
        [type] => varchar(14)
        [label] => ImportId
        [enabled] => 1
        [position] => 60
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
        [index] => 0
    )

[control_date] => Array
    (
        [type] => date
        [label] => ControlDate
        [enabled] => 1
        [position] => 63
        [notnull] => 0
        [visible] => 2
        [showinpwa] => 0
    )

[next_control_date] => Array
    (
        [type] => date
        [label] => NextControlDate
        [enabled] => 1
        [position] => 65
        [notnull] => 0
        [visible] => 2
        [showinpwa] => 0
    )

[success_rate] => Array
    (
        [type] => real
        [label] => SuccessScore
        [enabled] => 1
        [position] => 67
        [notnull] => 0
        [visible] => 2
        [showinpwa] => 0
        [help] => PercentageValue
    )

[status] => Array
    (
        [type] => smallint
        [label] => Status
        [enabled] => 1
        [position] => 70
        [notnull] => 1
        [visible] => 5
        [showinpwa] => 0
        [index] => 1
        [default] => 0
        [arrayofkeyval] => Array
            (
                [0] => Brouillon (à valider)
                [1] => Validé
                [2] => Verrouillé
                [3] => Archivé
            )

    )

[note_public] => Array
    (
        [type] => html
        [label] => NotePublic
        [enabled] => 1
        [position] => 80
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
    )

[note_private] => Array
    (
        [type] => html
        [label] => NotePrivate
        [enabled] => 1
        [position] => 90
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
    )

[verdict] => Array
    (
        [type] => smallint
        [label] => Verdict
        [enabled] => 1
        [position] => 110
        [notnull] => 0
        [visible] => 5
        [showinpwa] => 1
        [index] => 1
        [positioncard] => 20
        [arrayofkeyval] => Array
            (
                [0] => 
                [1] => OK
                [2] => KO
                [3] => N/A
            )

    )

[photo] => Array
    (
        [type] => text
        [label] => Photo
        [enabled] => 1
        [position] => 120
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
    )

[track_id] => Array
    (
        [type] => text
        [label] => TrackID
        [enabled] => 1
        [position] => 125
        [notnull] => 0
        [visible] => 2
        [showinpwa] => 0
    )

[fk_user_creat] => Array
    (
        [type] => integer:User:user/class/user.class.php
        [label] => UserAuthor
        [picto] => user
        [enabled] => 1
        [position] => 130
        [notnull] => 1
        [visible] => 0
        [showinpwa] => 0
        [foreignkey] => user.rowid
    )

[fk_user_modif] => Array
    (
        [type] => integer:User:user/class/user.class.php
        [label] => UserModif
        [picto] => user
        [enabled] => 1
        [position] => 140
        [notnull] => 0
        [visible] => 0
        [showinpwa] => 0
        [foreignkey] => user.rowid
    )

[fk_sheet] => Array
    (
        [type] => integer:Sheet:digiquali/class/sheet.class.php
        [label] => Sheet
        [picto] => fontawesome_fa-list_fas_#d35968
        [enabled] => 1
        [position] => 11
        [notnull] => 1
        [visible] => 5
        [showinpwa] => 0
        [index] => 1
        [css] => maxwidth500 widthcentpercentminusxx
        [foreignkey] => digiquali_sheet.rowid
    )

[fk_user_controller] => Array
    (
        [type] => integer:User:user/class/user.class.php:1
        [label] => Controller
        [picto] => user
        [enabled] => 1
        [position] => 12
        [notnull] => 1
        [visible] => 1
        [showinpwa] => 0
        [index] => 1
        [css] => maxwidth500 widthcentpercentminusxx
        [foreignkey] => user.rowid
        [positioncard] => 1
    )

[projectid] => Array
    (
        [type] => integer:Project:projet/class/project.class.php:1
        [label] => Project
        [picto] => project
        [enabled] => 1
        [position] => 13
        [notnull] => 0
        [visible] => 1
        [showinpwa] => 0
        [index] => 1
        [css] => maxwidth500 widthcentpercentminusxx
        [foreignkey] => projet.rowid
        [positioncard] => 2
    )

)

@eldy
Copy link
Member

eldy commented May 1, 2024

The method selectForForm is called with a parameter objectfield = control@digiquali:fk_productlot
So it means you want to output a combo list that show the content of data of the class defined into the field "fk_productlot" defined into the class control@digiquali. For example, if you have in the ->fields the property fk_productlot with type='integer:ProductLot', it means you want the content of table ProductLot.

But into the data you sent me, there is no field "fk_productlot" defined into ->fields of the class control@digiquali, so no way to guess the name of the class you want in the combo.

So having the error is the expected behaviour. There is a bad consistency between the code that mention "control@digiquali:fk_productlot" and the code into the class "control@digiquali" that miss "fk_productlot".

If you don't want to use the definition found into ->fields, the property "objectfield" must remain empty. In such a case, the selectForForm will use only the parameter objectdesc (for exemple ProductLot) to know which class to use.

@nicolas-eoxia
Copy link
Contributor Author

commonobject.class.php - L7726 / L7727
function showInputField
$objectfield = $this->element.($this->module ? '@'.$this->module : '').':'.$key.$keysuffix;
$out = $form->selectForForms($param_list_array[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, (empty($val['disabled']) ? 0 : 1), '', $objectfield);

In my case, with the use of element_element, I don't want to modify the object->fields of my object.
the objectfield parameter has become mandatory in commonobject, hence the proposal of this fix.

@eldy
Copy link
Member

eldy commented May 4, 2024

In my case, with the use of element_element, I don't want to modify the object->fields of my object. the objectfield parameter has become mandatory in commonobject, hence the proposal of this fix.

I still don't understand. You want to have an object that has a field that is a link to the property fk_productlot of the class control@digiquali but you don't want to have this property ?
In showInputField, the param $objectdesc is always defined, because showInputField should receive from the caller data coming from ->fields, so entry into ->field should always be found.

in your case, $key during the call of selectForForms is coming from where ? What is the class that is calling selectForForms ? Is it custom code that is calling selectForForms ? From where is coming the string "fk_productlot" propagated to selectForForms() ?

Can you try this fix:

fa75dc5?diff=split&w=1

and this one

0cce9ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected) Discussion Some questions or discussions are opened and wait answers of author or other people to be processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants