akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

Reordering replaces 'name' column data by views name on all records #619

Closed mikeazores closed 7 years ago

mikeazores commented 8 years ago

Hi!

I just came across a strange behaviour when reordering table rows in the backend if one of the table fields is called name. The name field data is replaced by the view name on all the records.

When I change the name field and call it differently (i.e. title) this is not happening:

    slt_georegion_id BIGINT(20) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
    title VARCHAR(255) NOT NULL,    <=
    slug VARCHAR(50) NOT NULL,
    summary MEDIUMTEXT NOT NULL,
    enabled TINYINT(3) unsigned DEFAULT '1' NOT NULL,
    image VARCHAR(255) DEFAULT '' NOT NULL,
    ordering BIGINT(20) DEFAULT '0' NOT NULL,
    created_by BIGINT(20) DEFAULT '0' NOT NULL,
    created_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
    modified_by BIGINT(20) DEFAULT '0' NOT NULL,
    modified_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
    locked_by BIGINT(20) DEFAULT '0' NOT NULL,
    locked_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL

If I change the name field to title field in the database table, this is not happening:

    slt_georegion_id BIGINT(20) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
    name VARCHAR(255) NOT NULL,    <=
    slug VARCHAR(50) NOT NULL,
    summary MEDIUMTEXT NOT NULL,
    enabled TINYINT(3) unsigned DEFAULT '1' NOT NULL,
    image VARCHAR(255) DEFAULT '' NOT NULL,
    ordering BIGINT(20) DEFAULT '0' NOT NULL,
    created_by BIGINT(20) DEFAULT '0' NOT NULL,
    created_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
    modified_by BIGINT(20) DEFAULT '0' NOT NULL,
    modified_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
    locked_by BIGINT(20) DEFAULT '0' NOT NULL,
    locked_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL

I'm using latest FOF3 version and Joomla 3.6.

nikosdion commented 8 years ago

It makes perfect sense since name is a reserved property name. There is no easy workaround that I am aware of :(

Nicholas Dionysopoulos Director, Akeeba Ltd

Sent from a mobile device. Please excuse my brevity.

On 28 Jul 2016, at 06:11, mikeazores notifications@github.com wrote:

Hi!

I just came across a strange behaviour when reordering a table rows in the backend if the table field has a name field. The name field data is replaced by the view name on all the records.

When I change the name field by other name (i.e. title) this is not happening:

slt_georegion_id BIGINT(20) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
**title** VARCHAR(255) NOT NULL,
slug VARCHAR(50) NOT NULL,
summary MEDIUMTEXT NOT NULL,
enabled TINYINT(3) unsigned DEFAULT '1' NOT NULL,
image VARCHAR(255) DEFAULT '' NOT NULL,
ordering BIGINT(20) DEFAULT '0' NOT NULL,
created_by BIGINT(20) DEFAULT '0' NOT NULL,
created_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
modified_by BIGINT(20) DEFAULT '0' NOT NULL,
modified_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
locked_by BIGINT(20) DEFAULT '0' NOT NULL,
locked_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL

If I change the name field to title field in the database table, this is not happening:

slt_georegion_id BIGINT(20) unsigned PRIMARY KEY NOT NULL AUTO_INCREMENT,
**name** VARCHAR(255) NOT NULL,
slug VARCHAR(50) NOT NULL,
summary MEDIUMTEXT NOT NULL,
enabled TINYINT(3) unsigned DEFAULT '1' NOT NULL,
image VARCHAR(255) DEFAULT '' NOT NULL,
ordering BIGINT(20) DEFAULT '0' NOT NULL,
created_by BIGINT(20) DEFAULT '0' NOT NULL,
created_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
modified_by BIGINT(20) DEFAULT '0' NOT NULL,
modified_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
locked_by BIGINT(20) DEFAULT '0' NOT NULL,
locked_on DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL

I'm using latest FOF3 version and Joomla 3.6.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Eighke commented 8 years ago

That strange I'm sure I had used name in the past without any problem and many times.

Eighke commented 8 years ago

Well, I confirm the bug, even on old version. I just never noticed, this is tricky.

Eighke commented 8 years ago

I guess just add in DataModel::bind()

                elseif ($data instanceof DataModel && isset($data->getFieldValue($k)))
                {
                    $this->setFieldValue($k, $data->getFieldValue($k));
                }