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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:48:19+00:00 2026-05-21T20:48:19+00:00

I’m having nice first days using Yii but have some troubles with getting things

  • 0

I’m having nice first days using Yii but have some troubles with getting things that i used to write ‘from the finger’ .

Here is the background for my question:

I created a ‘project’ model,controller and view (works fine) and in the ‘views/project/_form.php’ i put an ajax link that displays a partial view : a form that belongs to another model, named ‘picture’.

So, the ‘views/project/_form.php’ has this inside:

<?php

     echo CHtml::ajaxLink('Add picture', array('projekt/addPicture'), 
                                         array('update'=>'#req_res')
          );

?>

<div id="req_res">...</div> <!-- here the ajax form shows -->

The /project/addPicture action successfully shows the form using such code:

public function actionAddPicture()
    {

            $model=new Picture;
            $this->renderPartial('/projekt/_addPicture', array('model'=>$model));
            Yii::app()->end();
    }

and the ‘_addPicture.php’ file in the /projekt/view folder has a “cactiveform” inside, loading the ‘$model’ correctly (i can see my data stroed in the DB etc.)

Problem:

When i hit ‘save’ on the newly generated form, Yii sends me to a new white page containing again this form instead of saving it. Here’s the URL Yii sends me to:

      http://localhost/projekt/addPicture?_=1304644637668

I am vaguely aware that it may have something to do with me not telling Yii which controller to use (?) but i don’t know how to specify the controller (if this is the case)

Can you point me to some direction here? Thank you

  • 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-05-21T20:48:20+00:00Added an answer on May 21, 2026 at 8:48 pm

    By uesing cactiveform you define an action as an option of cactiveform:

    $form=$this->beginWidget('CActiveForm', array(
                             'action'=>Yii::app()->createUrl(...), ....
    

    Usually the action is “connected” to the save button you see at the form.

    When i hit 'save' on the newly generated form,
    

    btw: I think your Ajax-Link will not be used, if you click “save”

    me not telling Yii which controller to use (?)

    ..look at the “action” option from cactiveform

    Yii sends me to a new white page containing again this form instead of saving it

    That’s right. Because by using the default “save” button Yii executes the action. If the action is actionAddPicture, actually you don’t process the postes data.

    That means, you need something like that (just an simple example, which you have to customize for your needs):

    if(isset($_POST[<model>]) )  
        {   $model=new model();
            $model->attributes=$_POST[<model>];
            $model->save;
    [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,

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.