help
cannot see values , only labels why ?
if remove index from here return TextInput::make("{$prefix}_{$index}") see fullstring
[.] is divider
public static function form(Form $form): Form
{
$taskPostType = '38[.]38[.]38';
$taskPostAmount = '10[.]0[.]50';
$taskPostComment = 'test1[.]test2[.]test3';
//Function to split values by '[.]' and return the items $splitItems = function ($value) { return explode('[.]', $value); }; $generateFields = function ($items, $prefix) { return arraymap(function ($item, $index) use ($prefix) { return TextInput::make("{$prefix}{$index}") ->label("{$prefix} {$index}"); }, $items, array_keys($items)); }; // Generate fields $taskPostTypeFields = $generateFields($splitItems($taskPostType), 'Task_post_type'); $taskPostAmountFields = $generateFields($splitItems($taskPostAmount), 'Task_post_amount'); $taskPostCommentFields = $generateFields($splitItems($taskPostComment), 'Task_post_comment');
// Combine fields into schema $formSchema = array_merge( $taskPostTypeFields, $taskPostAmountFields, $taskPostCommentFields ); return $form ->schema([
Fieldset::make('Post Details')->columns(3) ->schema($formSchema),
])->columns(3); }
//Function to split values by '[.]' and return the items $splitItems = function ($value) { return explode('[.]', $value); }; $generateFields = function ($items, $prefix) { return arraymap(function ($item, $index) use ($prefix) { return TextInput::make("{$prefix}{$index}") ->label("{$prefix} {$index}"); }, $items, array_keys($items)); }; // Generate fields $taskPostTypeFields = $generateFields($splitItems($taskPostType), 'Task_post_type'); $taskPostAmountFields = $generateFields($splitItems($taskPostAmount), 'Task_post_amount'); $taskPostCommentFields = $generateFields($splitItems($taskPostComment), 'Task_post_comment');
// Combine fields into schema $formSchema = array_merge( $taskPostTypeFields, $taskPostAmountFields, $taskPostCommentFields ); return $form ->schema([
Fieldset::make('Post Details')->columns(3) ->schema($formSchema),
])->columns(3); }
1 Reply
Please check #✅┊rules for code formatting