FAQ Section Title, FAQ Section Description does not save empty values

Created on 20 March 2024, 8 months ago
Updated 22 March 2024, 8 months ago

FAQ Section Title, FAQ Section Description does not save empty values ​​(if they were filled earlier)
\src\Plugin\Block\FaqBlock.php

    public function blockSubmit($form, FormStateInterface $form_state) {
      foreach ($form_state->getValues() as $key => $value) {
        if ($key === 'items_fieldset') {
          if (isset($value['items'])) {
            $items = $value['items'];
/*WTpatch: incorrect PHPcode*/
            foreach ($items as $key2 => $item) { //foreach ($items as $key => $item) {
              if ($item['question'] === '' || !$item) {
                unset($items[$key2]); //unset($items[$key]);
/*<<<*/
              } else {
                if(isset($item['answer']['value']) && $item['answer']['value'] != '') {
                  $this->custom_editor_record_file_usage($item['answer']['value']);
                }
              }
            }
            $this->configuration['faq_items'] = $items;
          }
        }
/*WTpatch: possibility save empty value*/
        //if ($form_state->getValue('section_title') != null) {
          $this->configuration['section_title'] = $form_state->getValue('section_title');
        //}

        //if ($form_state->getValue('section_description') != null) {
          $this->configuration['section_description'] = $form_state->getValue('section_description');
        //}
/*<<<*/
        if ($form_state->getValue('toggle_icon_color') != null) {
πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @promo-il
  • Status changed to Needs work 8 months ago
  • πŸ‡³πŸ‡΅Nepal sujan shrestha NepalπŸ‡³πŸ‡΅, Kathmandu

    Hi @Promo-IL Thank you for letting me know. I'll review the code and ensure that everything aligns properly with the functionality. I appreciate your diligence in ensuring data integrity.

Production build 0.71.5 2024