/**
  * Add a block by first choosing the widget to use
  *
  * @param string $rowId Row to add this block to
  * @param int $columnIndex Numeric column index
  * @return void
  */
 public function add($rowId = null, $columnIndex = null)
 {
     $cmsRow = $this->CmsBlocks->CmsRows->get($rowId);
     $cmsPage = $this->CmsBlocks->CmsRows->CmsPages->getPage($cmsRow->cms_page_id);
     $cmsBlock = $this->CmsBlocks->newEntity();
     if ($this->request->is('post')) {
         $cmsBlock = $this->CmsBlocks->patchEntity($cmsBlock, $this->request->data);
         $cmsBlock->cms_row_id = $rowId;
         $cmsBlock->column_index = $columnIndex;
         $cmsBlock->status = 'active';
         if ($this->CmsBlocks->save($cmsBlock)) {
             $this->FrontendBridge->setJson('success', true);
             $this->FrontendBridge->setJson('triggerAction', 'editBlock');
             $this->FrontendBridge->setJson('blockId', $cmsBlock->id);
         } else {
             $this->Flash->error(__('forms.data_not_saved'));
         }
     }
     $widgetList = WidgetManager::getWidgetList();
     $widgets = [];
     foreach ($widgetList as $identifier => $config) {
         $widgets[$identifier] = sprintf('%s (%s)', $config['title'], $config['description']);
     }
     $this->set(compact('cmsBlock', 'widgets'));
 }