Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7976949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:03:10+00:00 2026-06-04T09:03:10+00:00

I am pretty new with MVC and Yii framework, therefore there is a good

  • 0

I am pretty new with MVC and Yii framework, therefore there is a good chance that my question is pretty stupid. If so, accept my appologies in advance.

I want to have a form in my admin section of the website, where, user can post some content. I followed the tutorial for sample blog however it seems that the content added to the fields that are defined as text in the database (textarea in my form) don’t get updated after submitting the form (everything else works fine). here is the sql statement for my table:

CREATE TABLE `tbl_show` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT,
   `presentation` text,
    PRIMARY KEY (`id`),
    KEY `fk_tbl_show_tbl_season1` (`tbl_season_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

I used Gii to make my Model and CRUD, I only add here the parts that might be related:

On my controller:

    public function actionCreate()
{
    $model=new Show;

    if(isset($_POST['Show']))
    {
        $model->attributes=$_POST['Show'];
        if($model->save())
                    {
                        $this->redirect(array('view','id'=>$model->id));
                    }   
    }
    $this->render('create',array(
        'model'=>$model,
    ));

and my _form.php:

<div class="form">

 <?php $form=$this->beginWidget('CActiveForm', array(
 'id'=>'show-form',
 'enableAjaxValidation'=>false,
  )); ?>

<?php echo $form->errorSummary($model); ?>

    <div class="row">
    <?php echo $form->labelEx($model,'presentation'); ?>
    <?php echo $form->textArea($model,'presentation',array('rows'=>6, 'cols'=>50)); ?>
    <?php echo $form->error($model,'presentation'); ?>
</div>

<div class="row buttons">
    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>

    <?php $this->endWidget(); ?>

    </div><!-- form -->

Model Rules:

return array(
    array('id, presentation', 'safe', 'on'=>'search'),
);

I don’t get why only the text content don’t get updated, they appear as null in the database.

Thank you in advance,
Cheers,
Mahsa

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:03:11+00:00Added an answer on June 4, 2026 at 9:03 am

    You have to make the attribute safe . Add this to your Show models validation rules

    array('presentation','safe')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to MVC 2 using the Entity Framework. I have two tables
I have a question that has pretty much been asked here: asp.net mvc Html.ActionLink()
I am a pretty new to the wonderful MVC framework KnockoutJS . Is it
I'm pretty new to using Entity Framework, as well as to using ASP.NET MVC.
I am pretty new to MVC and hope that I am approaching this the
I'm pretty new to MVC so this may seem like an obvious question, but
I'm hoping this is a rather simple question, but I'm pretty new to MVC
I'm pretty new to ASP.Net MVC. I've created a model that fills a List<>
I'm pretty new in the ASP .NET MVC world. Maybe, that's the reason I
Pretty new to MVC and the like. I have a class the looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.