Skip to content

Commit

Permalink
- add prompt translation
Browse files Browse the repository at this point in the history
- make whole field clickable to open the record finder form
  • Loading branch information
mjauvin committed Nov 21, 2024
1 parent 65ab300 commit 4d5c628
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion modules/backend/formwidgets/RecordFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RecordFinder extends FormWidgetBase
/**
* @var string Prompt to display if no record is selected.
*/
public $prompt = 'Click the %s button to find a record';
public $prompt = null;

/**
* @var int Maximum rows to display for each page.
Expand Down Expand Up @@ -144,6 +144,10 @@ public function init()
'modelClass',
]);

if (!isset($this->prompt)) {
$this->prompt = Lang::get('backend::lang.recordfinder.default_prompt');
}

if (!$this->useRelation && !class_exists($this->modelClass)) {
throw new ApplicationException(Lang::get('backend::lang.recordfinder.invalid_model_class', ['modelClass' => $this->modelClass]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ class="field-recordfinder loading-indicator-container size-input-text"
data-control="recordfinder"
data-refresh-handler="<?= $this->getEventHandler('onRefresh') ?>"
data-data-locker="#<?= $field->getId() ?>">
<span class="form-control" <?= $previewMode ? 'disabled="disabled"' : '' ?>>
<span class="form-control" style="cursor:pointer"
<?= $previewMode ? 'disabled="disabled"' : '' ?>
data-control="popup"
data-size="huge"
data-handler="<?= $this->getEventHandler('onFindRecord') ?>"
data-request-data="recordfinder_flag: 1"
>
<?php if ($value): ?>
<span class="primary"><?= e($nameValue) ?: 'Undefined' ?></span>
<?php if ($descriptionValue): ?>
Expand Down
1 change: 1 addition & 0 deletions modules/backend/lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
],
'recordfinder' => [
'find_record' => 'Find Record',
'default_prompt' => 'Click the %s button to find a record',
'invalid_model_class' => 'The provided model class ":modelClass" for the recordfinder is invalid',
'cancel' => 'Cancel',
],
Expand Down
1 change: 1 addition & 0 deletions modules/backend/lang/fr/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
'return_to_list' => 'Retourner à la liste'
],
'recordfinder' => [
'default_prompt' => 'Cliquer sur %s pour chercher un enregistrement',
'find_record' => 'Trouver un enregistrement',
'invalid_model_class' => "La classe du modèle \":modelClass\" fournie pour le recordfinder n'est pas valide.",
'cancel' => 'Annuler',
Expand Down

0 comments on commit 4d5c628

Please sign in to comment.