Skip to content

Commit

Permalink
Swap arguments of CrudViewHelper::field() for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 13, 2024
1 parent a3dcf6a commit a1365b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/View/Helper/CrudViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public function process(string $field, EntityInterface $data, array $options = [
/**
* Get the current field value
*
* @param \Cake\Datasource\EntityInterface|null $data The entity data.
* @param string $field The field to extract, if null, the field from the entity context is used.
* @param \Cake\Datasource\EntityInterface|null $data The entity data.
* @return mixed
*/
public function fieldValue(?EntityInterface $data, string $field): mixed
public function fieldValue(string $field, ?EntityInterface $data = null): mixed
{
if ($data === null) {
return $this->getContext()->val($field, ['schemaDefault' => false]);
Expand Down
2 changes: 1 addition & 1 deletion templates/element/index/gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?php foreach (${$viewVar} as $singularVar) : ?>
<div class="<?= $indexGalleryCssClasses ?>">
<?php
$imageAltContent = $this->CrudView->fieldValue($singularVar, $indexTitleField);
$imageAltContent = $this->CrudView->fieldValue($indexTitleField, $singularVar);
$titleContent = $this->CrudView->process($indexTitleField, $singularVar, $titleOptions);
$bodyContent = $this->CrudView->process($indexBodyField, $singularVar, $bodyOptions);
$imageContent = $this->CrudView->process($indexImageField, $singularVar, $imageOptions);
Expand Down

0 comments on commit a1365b7

Please sign in to comment.