2

I'm desiring to use this url:

index.php/form/2/fields/all

To output a list of fields with the same form id. Currently, I have a Form crud and a Fields crud.

FieldsController.php

public function actionAll()
{
  if (isset($_GET['form']))
  {
    $form_id = $_GET['form'];
    $model=$this->model()->findAllByAttributes(array('FORM_ID'=>$form_id), 'order'=> 'POSITION DESC');
    $this->render('all', array('model' => $model));
  }
  else
  {
    $this->render('error');
  }
}

What would the URLManager rule be?

Jeffrey
  • 4,098
  • 11
  • 42
  • 66

1 Answers1

0

Add named param with rule:

'form/<form:\d+>/fields/all' => 'fields/all'

You can even omit form

'<form:\d+>/fields/all' => 'fields/all'

Which will produce url 10/fields/all