<commit_before><?php
/**
 * @file
 * Containt Drupa\AppConsole\Command\Helper\FormTrait.
 */

namespace Drupal\AppConsole\Command\Helper;

use Symfony\Component\Console\Helper\HelperInterface;
use Symfony\Component\Console\Output\OutputInterface;

trait FormTrait
{
  /**
   * @param OutputInterface $output
   * @param HelperInterface $dialog
   * @return mixed
   */
  public function formQuestion(OutputInterface $output, HelperInterface $dialog)
  {
    if ($dialog->askConfirmation(
      $output,
      $dialog->getQuestion('Do you like generate a form structure?', 'yes', '?'),
      true
    )) {
      $input_types = [
        'color',
        'checkboxes',
        'date',
        'datetime',
        'email',
        'number',
        'range',
        'radios',
        'select',
        'tel',
        'textarea',
        'textfield',
      ];

      $inputs = [];
      while (true) {
        // Label for input
        $input_label = $dialog->ask(
          $output,
          $dialog->getQuestion(' Input label','',':'),
          null
        );

        if (empty($input_label)) {
          break;
        }

        // Machine name
        $input_machine_name = $this->getStringUtils()->createMachineName($input_label);

        $input_name = $dialog->ask(
          $output,
          $dialog->getQuestion('  Input machine name', $input_machine_name, ':'),
          $input_machine_name
        );

        // Type input
        $input_type = $dialog->askAndValidate(
          $output,
          $dialog->getQuestion('  Type', 'textfield',':'),
          function ($input) use ($input_types) {
            if (!in_array($input, $input_types)) {
              throw new \InvalidArgumentException(
                sprintf("Field Type \"%s\" is invalid.", $input)
              );
            }

            return $input;
          },
          false,
          'textfield',
          $input_types
        );

        $input_options = array();
        if(in_array($input_type, array('checkboxes', 'radios','select'))) {
          $input_options = $dialog->ask(
            $output,
            $dialog->getQuestion(' Input options separated by comma','',':'),
            null
          );
        }

        // Prepare options as an array
        if(!empty($input_options)) {
          // remove spaces in options and empty options
          $input_options = array_filter(array_map('trim', explode( ",", $input_options)));
          // Create array format for options
          $input_options = "array('" . implode("', '", $input_options) . "')";
        }

        array_push($inputs, array(<commit_msg>Enable add select, radios, checkboxes fields in form, with option to add options values<commit_after><?php
/**
 * @file
 * Containt Drupa\AppConsole\Command\Helper\FormTrait.
 */

namespace Drupal\AppConsole\Command\Helper;

use Symfony\Component\Console\Helper\HelperInterface;
use Symfony\Component\Console\Output\OutputInterface;

trait FormTrait
{
  /**
   * @param OutputInterface $output
   * @param HelperInterface $dialog
   * @return mixed
   */
  public function formQuestion(OutputInterface $output, HelperInterface $dialog)
  {
    if ($dialog->askConfirmation(
      $output,
      $dialog->getQuestion('Do you like generate a form structure?', 'yes', '?'),
      true
    )) {
      $input_types = [
        'color',
        'checkboxes',
        'date',
        'datetime',
        'email',
        'number',
        'range',
        'radios',
        'select',
        'tel',
        'textarea',
        'textfield',
      ];

      $inputs = [];
      while (true) {
        // Label for input
        $input_label = $dialog->ask(
          $output,
          $dialog->getQuestion(' Input label','',':'),
          null
        );

        if (empty($input_label)) {
          break;
        }

        // Machine name
        $input_machine_name = $this->getStringUtils()->createMachineName($input_label);

        $input_name = $dialog->ask(
          $output,
          $dialog->getQuestion('  Input machine name', $input_machine_name, ':'),
          $input_machine_name
        );

        // Type input
        $input_type = $dialog->askAndValidate(
          $output,
          $dialog->getQuestion('  Type', 'textfield',':'),
          function ($input) use ($input_types) {
            if (!in_array($input, $input_types)) {
              throw new \InvalidArgumentException(
                sprintf("Field Type \"%s\" is invalid.", $input)
              );
            }

            return $input;
          },
          false,
          'textfield',
          $input_types
        );

        $input_options = '';
        if(in_array($input_type, array('checkboxes', 'radios','select'))) {
          $input_options = $dialog->ask(
            $output,
            $dialog->getQuestion(' Input options separated by comma','',':'),
            null
          );
        }

        // Prepare options as an array
        if(strlen(trim($input_options))) {
          // remove spaces in options and empty options
          $input_options = array_filter(array_map('trim', explode( ",", $input_options)));
          // Create array format for options
          $input_options = "array('" . implode("', '", $input_options) . "')";
        }

        array_push($inputs, array(
{'fraction_non_alphanumeric': 0.14207855666228153, 'fraction_numerical': 0.0, 'mean_word_length': 1.917763157894737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '5194914', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1466, 'n_words': 315}