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
Page 1 of 1
Simpleworflow Allstatuslistdata Helper Not Returning Any Data
#2
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
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
#3
Posted 22 April 2013 - 05:08 AM
Raoul, 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

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
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.
#4
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
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
#5
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.
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.
#6
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 :
If you have a way to share your code I'll do my best to help you ...
ciao
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
#7
Posted 22 April 2013 - 09:44 AM
I had User model and it also inherited from CActiveRecord
The workflow definition file is in /protected/models/workflows/swUser
These are the result on the echo statements you recommended to check:
By the way my problem is on my actionAdmin, below is the code for the action:
Do I need to add some lines on the controller action?
Then this is the code in my _search.php view file.
Thanks.
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.
#8
Posted 22 April 2013 - 10:25 AM
my first guess is : try to comment the $model->unsetAttributes() line ...
Share this topic:
Page 1 of 1

Help












