I have two routes that I'm working on. One of them works and one of them does not. The UserEducation_Controller route works fine, but the UserEmployment_Controller does not. Here is my code:
This is what is my routes.yml file:
---
Name: userroutes
After: framework/routes#coreroutes
---
Director:
rules:
'user/education' : 'UserEducation_Controller',
'user/employment' : 'UserEmployment_Controller',
'user' : 'User_Controller'
---
Name: jobroutes
After: framework/routes#coreroutes
---
Director:
rules:
'job' : 'JobPosting_Controller'
This is my UserEducation.php file:
class UserEducation_Controller extends Page_Controller {
private static $allowed_actions = array(
'add',
'edit' => '->isOwner',
'remove' => '->isOwner',
'UserEducationForm',
'doAdd'
);
private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');
// INSERT NEW EDUCATION ENTRY
public function index()
{
$backUrl = $this->request->getVar('BackURL');
// If register success
if( $this->request->getVar('success') == 1 )
{
// Form submission was successful so redirect to BackURL
return $this->redirect( $backUrl );
}
return $this->renderWith(array('UserEducation', 'Page'));
}
}
This is my UserEmployment.php file:
class UserEmployment_Controller extends Page_Controller {
private static $allowed_actions = array(
'add',
'edit' => '->isOwner',
'remove' => '->isOwner',
'UserEmploymentForm',
'doAdd'
);
private static $url_handlers = array('edit/$ID' => 'index', 'add' => 'index');
// INSERT NEW EMPLOYMENT ENTRY
public function index()
{
Requirements::css('themes/simple/datetimepicker/jquery.datetimepicker.css');
$backUrl = $this->request->getVar('BackURL');
// If register success
if( $this->request->getVar('success') == 1 )
{
// Form submission was successful so redirect to BackURL
return $this->redirect( $backUrl );
}
return $this->renderWith(array('UserEmployment', 'Page'));
}
}
I tried switching the placement of the routes so the employment one comes first and then didn't change anything. The result is the same (education works, employment does not).
I created a public function init() method in my employment and did a die() statement in there and that didn't even hit so I'm guessing it's not even hitting the controller.
Any ideas? Thanks.
EDIT:
I even tried putting useremployment instead of user/employment to see if it was the nesting causing the problem and it still wouldn't work when I navigated to mysite.com/useremployment/add. I did the same with the usereducation and it still worked fine.. did a flush and dev/build.