showing blackhole error when i am using array type name in input field

249 Views Asked by At

admin_add_newsletter.ctp

foreach($menu_page_1 as $menu_pages) {
    echo $this->Form->checkbox('top_links.',array(
        'type'=>'checkbox','id'=>'checked_box',
        'value'=>$menu_pages['MenuPage']['id'],
        'label'=>false,'div'=>false,'hiddenField'=>false,
        'saparator'=>'</td><td>'
    ));
    echo '<label for="top_links'.$menu_pages['MenuPage']['id'].'">'.
        $menu_pages['MenuPage']['name'].'</label>';
}

NewsletterController.php

if($this->request->is('post')) {
    print_r($this->data['Newsletter']['top_links']['']);
    exit();
}

Error

The request has been black-holed

Error: The requested address '/admin/newsletters/add_newsletter' was not found on this server.

Stack Trace
CORE/Cake/Controller/Component/SecurityComponent.php line 239 → SecurityComponent->blackHole(NewslettersController, string)
[internal function] → SecurityComponent->startup(NewslettersController)
CORE/Cake/Utility/ObjectCollection.php line 132 → call_user_func_array(array, array)
[internal function] → ObjectCollection->trigger(CakeEvent)
CORE/Cake/Event/CakeEventManager.php line 247 → call_user_func(array, CakeEvent)
CORE/Cake/Controller/Controller.php line 675 → CakeEventManager->dispatch(CakeEvent)
CORE/Cake/Routing/Dispatcher.php line 182 → Controller->startupProcess()
CORE/Cake/Routing/Dispatcher.php line 160 → Dispatcher->_invoke(NewslettersController, CakeRequest, CakeResponse)
APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)

help me that how i use checkbox in cakephp that contain all the checked value from view file to controller without showing blackhole error.

1

There are 1 best solutions below

0
On

The problem is that you're manually building the checkbox options, and adding a dot in the field name.

The way to do this is to do this the Cake way:

$options = array();

foreach($menu_page_1 as $menu_pages) {
    $options[$menu_pages['MenuPage']['id']] = $menu_pages['MenuPage']['name'];
}
echo $this->Form->select('top_links', $options, array(
    'multiple' => 'checkbox'
));