Yii Framework Forum: Simpleworflow Allstatuslistdata Helper Not Returning Any Data - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Simpleworflow Allstatuslistdata Helper Not Returning Any Data Rate Topic: -----

#1 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 22 April 2013 - 02:47 AM

I used the simpleworflow extension and follow the instructions to setup here.
I got the other parts working aside from the allStatuslistData helper.
It is expected to return the list of all status.
echo $form->dropDownList($model,'status',SWHelper::allStatuslistData($model));
Do i missed something
0

#2 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 April 2013 - 03:20 AM

Hi Jan,
yes indeed, allStatuslistData should return a list of all status for the model.
Can you verify that your model is actually included into a workflow ? ... just echo $model->status
ciao
B)
0

#3 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 22 April 2013 - 05:08 AM

View PostRaoul, on 22 April 2013 - 03:20 AM, said:

Hi Jan,
yes indeed, allStatuslistData should return a list of all status for the model.
Can you verify that your model is actually included into a workflow ? ... just echo $model->status
ciao
B)


Thanks.
I did check if the workflow is included by using echo $model->status. And it return nothing.
By the way I used the allStatuslistData on _search.php view from the actionAdmin.
The codes there are auto generated.

Do i need to explicitly add the workflow? I assumed it would be added by having the behavior method on the corresponding model.
0

#4 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 April 2013 - 07:26 AM

Hi Jan,

If $model->status returns nothing, then your model is not in a workflow and it is normal that SWHelper::allStatuslistData($model) returns nothing as it can't find a workflow associated to $model.

So now the question is : how come your model is not in a workflow when you expected it to be ?

You're right, if you attache the behavior to the model, by default onAttach() the behavior will insert the model into a workflow named according to the model class name prefixed with 'sw'.

So, if you didn't set any attribute value in the behavior declaration, and assuming your model class name is Post your model should be automatically inserted into workflow swPost. Of course the definition of the swPost workflow should also be accessible and correct.

If you have logs enabled note that the simpleWorkflow extension logs into the category "application.simpleWorkflow" ...

ciao
B)
0

#5 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 22 April 2013 - 09:01 AM

Hi Raoul,

I assume lines below on my model add it to the workflow:

function behaviors()
{
return array(
'swBehavior'=>array(
'class' => 'application.extensions.simpleWorkflow.SWActiveRecordBehavior',
),
);
}

I also add necessary configurations on the components:
'swSource'=> array(
'class'=>'application.extensions.simpleWorkflow.SWPhpWorkflowSource',
),

as well as the import:
'application.extensions.simpleWorkflow.*', // Import simpleWorkflow extension

Can you help me point out what I missed?
I'm new to Yii, this is just my second week working on it.

Thanks.
0

#6 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 April 2013 - 09:36 AM

This seems to be correct.

What about the workflow definition file itself ? What is the class name of your model ? Does it inherit from CActiveRecord ?

You could try to print :

   echo $model->swGetDefaultWorkflowId();
   echo $model->swGetWorkflowId();


If you have a way to share your code I'll do my best to help you ...


ciao
B)
0

#7 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 22 April 2013 - 09:44 AM

I had User model and it also inherited from CActiveRecord
class User extends CActiveRecord


The workflow definition file is in /protected/models/workflows/swUser
<?php
	return array(
		'initial' => 'New',
		'node' => array(
			array('id'=>'New', 'transition'=>'Active'),
			array('id'=>'Active', 'transition'=>'Inactive')
		)
	);
?>



These are the result on the echo statements you recommended to check:

swGetDefaultWorkflowId: swUser
swGetWorkflowId: 


By the way my problem is on my actionAdmin, below is the code for the action:
$model=new User('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['User']))
			$model->attributes=$_GET['User'];	

		$this->render('admin',array(
			'model'=>$model,
		));


Do I need to add some lines on the controller action?

Then this is the code in my _search.php view file.
<?php echo $form->dropDownList($model,'status',SWHelper::allStatuslistData($model)); ?> 



Thanks.
0

#8 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 633
  • Joined: 29-November 08
  • Location:Paris, France

Posted 22 April 2013 - 10:25 AM

my first guess is : try to comment the $model->unsetAttributes() line ...
8)
0

#9 User is offline   Markz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 16-April 13

Posted 05 May 2013 - 10:57 PM

Thanks for the help.

I got it now.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users