Simpleworflow Allstatuslistdata Helper Not Returning Any Data
Posted 22 April 2013 - 02:47 AM
I got the other parts working aside from the allStatuslistData helper.
It is expected to return the list of all status.
Do i missed something
Posted 22 April 2013 - 05:08 AM
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
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.
Posted 22 April 2013 - 07:26 AM
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" ...
Posted 22 April 2013 - 09:01 AM
I assume lines below on my model add it to the workflow:
'class' => 'application.extensions.simpleWorkflow.SWActiveRecordBehavior',
I also add necessary configurations on the components:
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.
Posted 22 April 2013 - 09:36 AM
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 ...
Posted 22 April 2013 - 09:44 AM
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)); ?>