-
Notifications
You must be signed in to change notification settings - Fork 106
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
Feature/card improvements #2025
base: develop
Are you sure you want to change the base?
Conversation
…ample, form layout class
…n (probably custom) template
@@ -147,7 +152,7 @@ public function setModel(Model $model, array $fields = null, array $extra = null | |||
if ($count) { | |||
foreach ($this->model as $m) { | |||
/** @var Card */ | |||
$c = $this->cardHolder->add(Factory::factory([$this->card], ['useLabel' => $this->useLabel, 'useTable' => $this->useTable])); | |||
$c = $this->cardHolder->add(Factory::factory((array) $this->card, ['useLabel' => $this->useLabel, 'useTable' => $this->useTable])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never use (array)
cast, change the def. value to be an array seed instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will work on that a bit more probably tomorrow. Looks like there are more seed related things to fix in this (and Card) classes for consistency with other views and also to ease extending.
@@ -157,7 +157,7 @@ protected function _setOrAppend($tag, string $value = null, bool $encodeHtml = t | |||
// in this case we don't throw exception if tags don't exist | |||
if (is_array($tag) && $value === null) { | |||
foreach ($tag as $k => $v) { | |||
$this->_setOrAppend($k, $v, $encodeHtml, $append, false); | |||
$this->_setOrAppend($k, (string) $v, $encodeHtml, $append, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never cast to a string, string type is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if you use ->set($model)
, then it will try to set model id
which is integer into template too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see l153/typecasting above, this is already fully handled when set thru model, we cannot do it with array, as php type itself is not enought to determine DBAL/typecasting type, since #1987 we format int
using UI persistence config, so (string)
will not produce desired output
@@ -64,15 +64,15 @@ public function addFields(Model $model, array $fields, bool $useLabel = false, b | |||
/** | |||
* Add fields label and value to section. | |||
*/ | |||
private function addSectionFields(Model $model, array $fields, bool $useLabel = false): void | |||
protected function addSectionFields(Model $model, array $fields, bool $useLabel = false): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Private methods are often added as the API might not be well defined. If private, we do not have to care, but if protected, we need to support the API in a long term. Please confirm you understand this and also there are no simillar private methods in other components.
Multiple improvements for Card and CardDeck - see description of commits.
Also adds additional demo how we can create CardDeck with custom Cards.