kramx7
(Kramx7)
April 22, 2013, 7:47am
1
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
Raoul
(Manu34)
April 22, 2013, 8:20am
2
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
kramx7
(Kramx7)
April 22, 2013, 10:08am
3
Raoul:
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
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.
Raoul
(Manu34)
April 22, 2013, 12:26pm
4
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
kramx7
(Kramx7)
April 22, 2013, 2:01pm
5
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.
Raoul
(Manu34)
April 22, 2013, 2:36pm
6
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
kramx7
(Kramx7)
April 22, 2013, 2:44pm
7
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.
Raoul
(Manu34)
April 22, 2013, 3:25pm
8
my first guess is : try to comment the $model->unsetAttributes() line …