Skip to content

Trying to loadEavAttributes on empty owner model returns corrupteed SQL #10

Description

@alexglue

Action for create an object::view

    <?php
    if(!$model->isNewRecord) $model->getEavAttributes();
    foreach (['attr1', 'attr2', 'attr3'] as $name){?>
        <?= $form->textAreaGroup($model,'eavAttributes['.$name.']', array('widgetOptions'=>array(
            'htmlOptions'=>array('rows'=>6, 'cols'=>50)
        ))); ?>
    <?}?>

calling this:

    public function loadEavAttributes($attributes)

and now we have smth like this on empty object primary key (new entity adding):

SELECT * FROM `project_eav` `t` WHERE (object_id = ) AND (attribute IN (:ycp0, :ycp1, :ycp2))

The solution is to fix EEavBehavior:

    public function loadEavAttributes($attributes) {
        if(is_null($this->getModelId())){ //[+]
            return $this->getOwner(); //[+]
        } //[+]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions