Skip to content

HasOneSQL::addField does not support save (editable)#933

Closed
mvorisek wants to merge 2 commits intodevelopfrom
hasone_is_noneditable
Closed

HasOneSQL::addField does not support save (editable)#933
mvorisek wants to merge 2 commits intodevelopfrom
hasone_is_noneditable

Conversation

@mvorisek
Copy link
Copy Markdown
Member

fixes #929

expected behaviour seems described in

/**
* Array with UI flags like editable, visible and hidden.
*
* By default hasOne relation ID field should be editable in forms,
* but not visible in grids. UI should respect these flags.
*
* @var array
*/
public $ui = [];

but there are some hooks I do not fully understand their general purpose

https://github.com/atk4/data/blob/develop/src/Reference/HasOneSql.php#L49-L59

and HasOne class has these

https://github.com/atk4/data/blob/develop/src/Reference/HasOne.php#L77-L114

but these are not used for HasOneSql::addField, as field is created using refLink nad ref is not called at all

@georgehristov @DarkSide666 @ibelar what do you think, what should be the expected behaviour and how to resolve the issue above?

public function isEditable(): bool
{
return $this->ui['editable'] ?? !$this->read_only && !$this->never_persist && !$this->system;
return $this->ui['editable'] ?? !$this->read_only && !$this->never_persist && !$this->never_save && !$this->system;
Copy link
Copy Markdown
Member Author

@mvorisek mvorisek Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the real difference between read_only and never_save?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion from chat:

return $this->ui['editable'] ?? !$this->read_only && !$this->system;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the condition above and it does not fix the atk4/filestore issue described in #929

@mvorisek mvorisek force-pushed the hasone_is_noneditable branch from 14b72b5 to baf72e6 Compare December 3, 2021 23:56
@mvorisek mvorisek force-pushed the hasone_is_noneditable branch from baf72e6 to 96ee7a4 Compare December 12, 2021 22:59
@mvorisek mvorisek added the bug label Dec 30, 2021
@mvorisek mvorisek force-pushed the hasone_is_noneditable branch 2 times, most recently from c4af374 to 93c4c30 Compare May 30, 2022 12:35
@mvorisek mvorisek marked this pull request as draft June 3, 2022 16:19
@mvorisek mvorisek force-pushed the hasone_is_noneditable branch from 93c4c30 to adca6a9 Compare June 25, 2022 08:43
@mvorisek mvorisek force-pushed the hasone_is_noneditable branch from adca6a9 to e22abb4 Compare July 7, 2022 13:25
@mvorisek mvorisek force-pushed the hasone_is_noneditable branch 2 times, most recently from 2d343ee to ad01b0d Compare July 23, 2022 11:38
@mvorisek mvorisek deleted the hasone_is_noneditable branch July 30, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

HasOneSql::addField adds field without ->ui['editable'] = false, but it is not saveable

1 participant