In release https://www.drupal.org/project/drupal/releases/9.2.13 security patch added to form builder. after that field type "value" doesn't return any values in form submit function for table_select.

Not sure what changes needs to be done to the form, if any one knows please add in comments. Or if it's an issue then this needs to worked on at core level.

I have added Form code which used to work, but after 9.2.13 doesn't work. Now form doesn't return "comment" field values in submitForm function but "comment" values available in both $_REQUEST $_POST.


namespace Drupal\example_module\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Exception;

/**
 * Provide a form to create returns.
 */
class ReturnForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'example_table_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    
      $options = [
      [
        'title' => 'How to Learn Drupal', 
        'content_type' => 'Article', 
        'status' => 'published', 
        'comment' => ['data'=> [
            '#type' => 'textfield', 
            '#title' => 'Comment for row1',
            '#title_display'=> 'invisible',
            '#name' => 'comment[1]',
            '#access' => TRUE,
            '#disabled' => FALSE,
          ],
        ],
      ], 
      [
        'title' => 'Privacy Policy', 
        'content_type' => 'Page', 
        'status' => 'published', 
        'comment' => ['data'=> [
            '#type' => 'textfield',
            '#title' => 'Comment for row2',
            '#title_display' => 'invisible',
            '#name' => 'comment[2]',
            '#access' => TRUE,
            '#disabled' => FALSE,
           ],
         ],
      ],
    ];
    $header = [
      'title' => 'Title',
      'content_type' => 'Content type',
      'status' => 'Status',
      'comment' => 'Comment',
    ];

    $form['tableselect_element'] = [
      '#type' => 'tableselect',
      '#header' => $header,
      '#options' => $options,
      '#empty' => 'No content available.',
    ];

    $form['comment'] = [
      '#type' => 'value',
    ];
   
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#name' => 'proceed',
      '#button_type' => 'primary',
      '#value' => $this->t('Proceed'),
      '#weight' => 10,
    ];

    $form['#cache'] = ['max-age' => 0];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    
    
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    echo '<pre>&#039; . print_r(, TRUE) . &#039;</pre>';exit;
  }

}

For more details please check below links
Release page - https://www.drupal.org/project/drupal/releases/9.2.13
security page - https://www.drupal.org/sa-core-2022-003
changes can be viewed here Changes can be viewd here - https://github.com/drupal/drupal/commit/7401e2ade3602125b244b6cbe082d555....

Comments

dvmanjunath created an issue. See original summary.

cilefen’s picture

Category: Bug report » Support request
Priority: Major » Normal
Issue tags: -table_select, -field type value, -9.3.13 release notes

According to its documentation "value" has to actually be set with a value when it is declared. It cannot be set in the form post.

My guess is that the code above was depending on the bug behavior to work.

cilefen’s picture

Status: Active » Closed (outdated)

There have been no updates.