#help

1 messages · Page 1 of 1 (latest)

torpid gorge
#

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 array_map(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);

}
maiden saddleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution