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 9118059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:03:08+00:00 2026-06-17T05:03:08+00:00

I have a model(table with 2 fields name(pk) and text). I need to show

  • 0

I have a model(table with 2 fields name(pk) and text). I need to show the data in these forms and update it from the page.
I’m able to show the form by using this

<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

but how to show the content from the table into each section and how to update the data.

index.php is like this:

<p>some & Text</p>
    <p>
        <?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
    </p>
    <p>Some more  Text</p>
    <p>
        <?php echo $this->renderPartial('_form', array('model'=>$model)); ?>
    </p>
    <p>Little More Text</p>
    <p>
        <?php echo $this->renderPartial('_form', array('model'=>$model)); ?>    
    </p>

my _form.php is like this:

<div class="form">

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

    <p class="note">Fields with <span class="required">*</span> are required.</p>

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

    <div class="row">
        <?php echo $form->labelEx($model,'name'); ?>
        <?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
        <?php echo $form->error($model,'name'); ?>
    </div>

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

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

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

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

What should be my url for the index.php in order to show the content from the table.(at the moment I’m using localhost/webapp/controller.. and its displaying with form 3 times.

  • 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-17T05:03:09+00:00Added an answer on June 17, 2026 at 5:03 am

    got it.. I’ve solved my self using Collecting Tabular Input
    I’m able to achieve what I’m looking for with
    Collecting Tabular Input
    http://www.yiiframework.com/doc/guide/1.1/en/form.table

    Thanks all 🙂

    my controller:

    public function actionBatchUpdate()
        {
                $item = new Model;
    
                $items=Model::model()->findAll();
    
    
    
    
    
                if(isset($_POST['Model']))
                {
    
                        $valid=true;
                        foreach($items as $i=>$item)
                        {
                                if(isset($_POST['Model'][$i]))
    
                                $item->attributes=$_POST['Model'][$i];
                                $valid=$item->validate() && $valid;
                                if($valid)$item->save();
                        }
    
    
                }
    
                // displays the view to collect tabular input
                $this->render('batchUpdate',array(
                                'items'=>$items));
    
        }
    

    my view file:

    my view file batchupdate.php is:

    <div class="form">
    <?php echo CHtml::beginForm(); ?>
    <table>
    
    <?php foreach($items as $i=>$item): ?>
    <tr style=" border-bottom: solid 1px black;">
    <p><td><?php echo CHtml::activeTextField($item,"[$i]name",$htmlOptions=array('disabled'=>'disabled')); ?></td></p>
    </tr>
    
    
    <tr style=" border-bottom: solid 2px black;">
    <p><td><?php echo CHtml::activeTextArea($item,"[$i]text",$htmlOptions=array ('rows'=>8,'cols'=>60));?></td></p></tr> 
    
     <tr style=" border-bottom: solid 1px black;">
    <p><td><?php echo CHtml::submitButton('Save');?></td></p></tr>
    <tr>
    <td><hr size="10" width="100%" /></td>
    </tr>
    
    <?php endforeach; ?>
    </table>
    
    
    <?php echo CHtml::endForm(); ?>
    </div><!-- form -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model like this class Task(models.Model): name = models.CharField(max_length=100) ... class TaskForm(forms.ModelForm):
I have Doctrine 2.1 entity: /** * @Entity(repositoryClass=Varlab\Model\Repository\UserRepository) * @Table(name=user) */ class User {
i have recs model mapping to a recs table in postgresql, some fields are
Suppose that i have a table 't' with fields 'id' int 11, 'name' varchar
I have the following fields in my table Name NameId City ----- ------ -------
I have product_details table which belongs to categories. product_details has fields like id, name,
I have this model in web2py DAL: db.define_table('category', Field('name','string'), format='%(name)s' ) db.define_table('uploaded_question', Field('text','string'), ...
I have a table name 'payroll' in my DB having the fields salary, bonus,
I have a Django model with a large number of fields and 20000+ table
I got a simple problem in SQLAlchemy. I have one model in a table,

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.