Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a delete page form in Yii Framework?
    text
    copied!<p>I know that usually you would just use the integrated CRUD delete button that is in admin however for my purposes I am requiring an actual page for delete that just has the id in a field and a submit button but so far it just produces the error view so any assistance is appreciated. I have tried to create it the same as my create and update pages are set up, please see the code below:</p> <p><strong>The link to the delete page:</strong></p> <pre><code>&lt;?php echo CHtml::link('Delete Article', array('delete', 'id'=&gt;$pageid)); ?&gt; </code></pre> <p><strong>The link it produces:</strong></p> <pre><code>http://local/..../Yii/news/index.php/delete?id=3 </code></pre> <p><strong>The controller:</strong></p> <pre><code>public function actionDelete($id) { $model=$this-&gt;loadModel($id); if(isset($_POST['news_model'])) { $model-&gt;attributes=$_POST['news_model']; if($model-&gt;save()) $this-&gt;redirect('index'); } $this-&gt;render(array('delete', array( 'model'=&gt;$model, )); } </code></pre> <p><strong>Delete.php:</strong></p> <pre><code>&lt;h2&gt;Delete a news item&lt;/h2&gt; &lt;?php echo $this-&gt;renderPartial('_form2', array('model'=&gt;$model)); ?&gt; </code></pre> <p><strong>_form2.php</strong></p> <pre><code>&lt;?php echo $form-&gt;errorSummary($model); ?&gt; &lt;?php $form=$this-&gt;beginWidget('CActiveForm', array( 'id'=&gt;'news-model-form', 'enableAjaxValidation'=&gt;false, )); ?&gt; &lt;div class="form"&gt; &lt;div class="row"&gt; &lt;?php echo $form-&gt;labelEx($model,'id'); ?&gt;&lt;br&gt; &lt;?php echo $form-&gt;textField($model,'id',array('size'=&gt;50,'maxlength'=&gt;128)); ?&gt; &lt;?php echo $form-&gt;error($model,'id'); ?&gt; &lt;/div&gt;&lt;br&gt; &lt;div class="row buttons"&gt; &lt;?php echo CHtml::submitButton($model-&gt;isNewRecord ? 'Delete a news item'); ?&gt; &lt;/div&gt; &lt;?php $this-&gt;endWidget(); ?&gt; &lt;/div&gt;&lt;!-- form --&gt; </code></pre> <p>Thanks in advance for any help given.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload