Bonjour,
Je suis en train de développer un site web et son panel admin. J'utilise donc le FormHelper de CakePHP mais une erreur parvient a la soumission : "The request has been black-holed" Et je sais que c'est de type auth grâce à la fonction
public function blackhole($type).
admin_view.ctp :
<div class="row-fluid">
<!-- Forms: Box -->
<div class="span12">
<!-- Forms: Top Bar -->
<div class="top-bar">
<h3><i class="icon-cog"></i> Modification d'une nouveautée</h3>
</div>
<!-- / Forms: Top Bar -->
<!-- Forms: Content -->
<div class="well no-padding">
<!-- Forms: Form -->
<?php
echo $this->Form->create('News', array(
'class' => 'form-horizontal'
));
?>
<div class="control-group">
<label class="control-label">ID</label>
<div class="controls">
<input class="span6 m-wrap" type="text" placeholder="<?= $id ?>" disabled="">
<span class="help-inline">Vous ne pouvez pas changé l'id de la nouveautée</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Titre</label>
<div class="controls">
<?php
$this->Form->unlockField('News.content');
echo $this->Form->input('', array(
'type' => 'text',
'name' => 'title',
'class' => 'span6 m-wrap',
'value' => $title,
'placeholder' => 'Titre'
));
?>
</div>
</div>
<div class="control-group">
<label class="control-label">Auteur</label>
<div class="controls">
<input class="span6 m-wrap" type="text" placeholder="<?= $author ?>" disabled="">
<span class="help-inline">Celui qui a publié la nouveautée</span>
</div>
</div>
<div class="control-group">
<?= $this->Html->script('tinymce/tinymce.min.js') ?>
<script type="text/javascript">
tinymce.init({
selector: "textarea",
height : 300,
width : '100%',
language : 'fr_FR'
});
</script>
<?php
$this->Form->unlockField('News.content');
echo $this->Form->textarea('News.content', array('value' => $content));
?>
</div>
<div class="form-actions">
<?php
echo $this->Form->button('Envoyer', array(
'type' => 'submit',
'class' => 'btn btn-primary'
));
?>
<a href="../../" class="btn">Annuler</a>
</div>
<?php echo $this->Form->end(); ?>
<!-- / Forms: Form -->
</div>
<!-- / Forms: Content -->
</div>
<!-- / Forms: Box -->
</div>
NewsController.php (Fonction admin_view):
public $components = array('Security');
public function beforeFilter() {
$this->Security->blackHoleCallback = 'blackhole';
}
public function blackhole($type) {
echo '<h3><center>Un problème est survenu ! Type : '.$type.'</center></h3>';
$this->layout = null;
}
public function admin_view($id = false) {
if(!$id) {
$this->redirect('../news');
}
// Thème
$this->layout = "admin";
// Variable d'infos
$this->loadModel('User');
$search_members = $this->User->find('all'); $this->set(compact('search_members'));
$count_members = $this->User->find('count'); $this->set(compact('count_members'));
$this->loadModel('Visit');
$count_visits = $this->Visit->find('count'); $this->set(compact('count_visits'));
$this->loadModel('News');
$count_news = $this->News->find('count'); $this->set(compact('count_news'));
$this->loadModel('Comment');
$count_comments = $this->Comment->find('count'); $this->set(compact('count_comments'));
$title_for_layout = "Modification d'une news"; $this->set(compact('title_for_layout'));
$view_news = $this->News->find('all', array(
'conditions' => 'id='.$id
));
if(!$view_news) {
$this->redirect('../news');
}
$id = $view_news'0']'News']'id']; $this->set(compact('id'));
$title = $view_news'0']'News']'title']; $this->set(compact('title'));
$content = $view_news'0']'News']'content']; $this->set(compact('content'));
$created = $view_news'0']'News']'created']; $this->set(compact('created'));
$author = $view_news'0']'News']'author']; $this->set(compact('author'));
$like = $view_news'0']'News']'like']; $this->set(compact('like'));
}
Comment faire ?
Merci d'avance,
Cordialement,
Eywek.
Sans le code de la fonction et la vue on peut pas deviner....
Tu as pas du JS sur ce formulaire ?
Excusez moi j'ai oublier de mettre le code, j'édite mon post.
Sinon oui j'ai du JavaScript étant donné que j'utilise un WYSIWYG.