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>' . print_r(, TRUE) . '</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....
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2022-08-10 at 8.43.45 PM.png | 263.08 KB | dvmanjunath | |
| Screenshot 2022-08-10 at 8.40.19 PM.png | 353.54 KB | dvmanjunath |
Comments
Comment #2
cilefen commentedAccording 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.
Comment #3
cilefen commentedThere have been no updates.