<commit_before><?php

namespace Civi\Api4\Service\Spec\Provider;

use Civi\Api4\Service\Spec\FieldSpec;
use Civi\Api4\Service\Spec\RequestSpec;

class CustomFieldCreationSpecProvider implements Generic\SpecProviderInterface {

  /**
   * @inheritDoc
   */
  public function modifySpec(RequestSpec $spec) {
    $optionField = new FieldSpec('option_values', $spec->getEntity(), 'Array');
    $optionField->setTitle(ts('Option Values'));
    $optionField->setDescription('Pass an array of options (value => label) to create this field\'s option values');
    $spec->addFieldSpec($optionField);
  }

  /**
   * @inheritDoc
   */
  public function applies($entity, $action) {
    return $entity === 'CustomField' && $action === 'create';
  }

}
<commit_msg>Set customField data_type default = 'String'<commit_after><?php

namespace Civi\Api4\Service\Spec\Provider;

use Civi\Api4\Service\Spec\FieldSpec;
use Civi\Api4\Service\Spec\RequestSpec;

class CustomFieldCreationSpecProvider implements Generic\SpecProviderInterface {

  /**
   * @inheritDoc
   */
  public function modifySpec(RequestSpec $spec) {
    $optionField = new FieldSpec('option_values', $spec->getEntity(), 'Array');
    $optionField->setTitle(ts('Option Values'));
    $optionField->setDescription('Pass an array of options (value => label) to create this field\'s option values');
    $spec->addFieldSpec($optionField);
    $spec->getFieldByName('data_type')->setDefaultValue('String')->setRequired(FALSE);
  }

  /**
   * @inheritDoc
   */
  public function applies($entity, $action) {
    return $entity === 'CustomField' && $action === 'create';
  }

}

{'fraction_non_alphanumeric': 0.1498150431565968, 'fraction_numerical': 0.0036991368680641184, 'mean_word_length': 4.674825174825175, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2370277', 'n_tokens_mistral': 487, 'n_tokens_neox': 483, 'n_words': 99}