Skip to content

Commit 0eb461d

Browse files
thewebartisan7mitulgolakiya
authored andcommitted
fix: Suggested solution for issue #887 (#891)
* Suggested solution for issue #887 Replacing `$FIELD_NAME$` before `fill_template_with_field_data_locale()` otherwise also `$FIELD_NAME$` get replaced with `@lang('models/$modelName.fields.$value')` and so we don't have `$FIELD_NAME$` in `table_header_locale.stub`. @see issue #887 We could need 'raw' field name in header for example for sorting. We still have $FIELD_NAME_TITLE$ replaced with @lang('models/$modelName.fields.$value') * Update ViewGenerator.php * Fix comments * Update ViewGenerator.php * Update ViewGenerator.php * Finally last I hope
1 parent b9d0a06 commit 0eb461d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Generators/Scaffold/ViewGenerator.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,21 @@ private function generateTableHeaderFields()
175175
}
176176

177177
if ($localized) {
178+
/**
179+
* Replacing $FIELD_NAME$ before fill_template_with_field_data_locale() otherwise also
180+
* $FIELD_NAME$ get replaced with @lang('models/$modelName.fields.$value')
181+
* and so we don't have $FIELD_NAME$ in table_header_locale.stub
182+
* We could need 'raw' field name in header for example for sorting.
183+
* We still have $FIELD_NAME_TITLE$ replaced with @lang('models/$modelName.fields.$value').
184+
*
185+
* @see issue https://github.com/InfyOmLabs/laravel-generator/issues/887
186+
*/
187+
$preFilledHeaderFieldTemplate = str_replace('$FIELD_NAME$', $field->name, $headerFieldTemplate);
188+
178189
$headerFields[] = $fieldTemplate = fill_template_with_field_data_locale(
179190
$this->commandData->dynamicVars,
180191
$this->commandData->fieldNamesMapping,
181-
$headerFieldTemplate,
192+
$preFilledHeaderFieldTemplate,
182193
$field
183194
);
184195
} else {

0 commit comments

Comments
 (0)