<?php // $file = /home/bluedoor/www/dev/wp-content/plugins/yooessentials/modules/form/actions/SaveCsv/config.json

return [
  'name' => 'save-csv', 
  'title' => 'Save to CSV', 
  'group' => 'data', 
  'description' => 'Save data to a CSV formatted file.', 
  'icon' => $filter->apply('url', '~yooessentials_url/modules/form/actions/SaveCsv/icon.svg', $file), 
  'fields' => [
    'file' => [
      'label' => 'File', 
      'description' => 'The CSV file where the submission data will be appended to.', 
      'type' => 'yooessentials-file'
    ], 
    'content' => [
      'label' => 'Columns', 
      'type' => 'yooessentials-dataset-mapping', 
      'description' => 'Enable each column that should contain content, set a static or dynamic value inside it configuration panel. Leaving all columns empty will result in a blank row appended.', 
      'endpoint' => 'yooessentials/form-action/savecsv/columns', 
      'watch' => 'file,separator,enclosure', 
      'enable' => 'file', 
      'panel' => [
        'title' => 'Content', 
        'fields' => [
          'value' => [
            'label' => 'Value', 
            'source' => true, 
            'description' => 'The value for this data entry.'
          ]
        ]
      ]
    ], 
    'separator' => [
      'label' => 'Delimiter', 
      'attrs' => [
        'placeholder' => ','
      ]
    ], 
    'enclosure' => [
      'label' => 'Enclosure', 
      'attrs' => [
        'placeholder' => '"'
      ]
    ], 
    'name' => $config->get('yooessentials.form.fields.action_name'), 
    'status' => $config->get('yooessentials.form.fields.action_status'), 
    'conditions' => $config->get('yooessentials.form.fields.action_conditions')
  ], 
  'fieldset' => [
    'default' => [
      'type' => 'tabs', 
      'fields' => [[
          'title' => 'Action', 
          'fields' => ['file', [
              'description' => 'The delimiter and enclosure characters the CSV file is formated with.', 
              'name' => '_csv_format', 
              'type' => 'grid', 
              'width' => '1-2', 
              'fields' => ['separator', 'enclosure']
            ], 'content']
        ], [
          'title' => 'Advanced', 
          'fields' => ['name', 'status', 'conditions']
        ]]
    ]
  ]
];
