Пожалуйста, смотрите мой вопрос в разделе шаблона ниже:
Форма (showSuccess):
<?php echo form_tag('job/salarySubmit') ?>
<input type="hidden" name="job_id" value="<?php echo $job->getId(); ?>">
<input type="submit" value="View Salary">
</form>
Действие:
public function executeSalarySubmit(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod('post'));
$param = array('job_id' => $request->getParameter('job_id'), );
$this->redirect('job/salary?'.http_build_query($param));
}
public function executeSalary(sfWebRequest $request)
{
$this->object_id = $request->getParameter('job_id');
$this->salary = $this->getRoute()->getObject();
}
Шаблон (salarySuccess.php):
<?php echo $object_id; ?> // returns correct job_id: 6100, but when I try to access the object's other getters (example: echo $object_id->getName(), I get "Fatal error: Call to a member function getName() on a non-object"
<?php echo $salary->getName(); ?> //works, but it gets the wrong name. It's returning the first job in my DB with an ID of "1" which is not correct... it needs to be 6100
Маршрутизация:
job_salary:
url: /job/salary/:job_id
param: { module: job, action: salary }
class: sfDoctrineRoute
options: { model: Job, type: object }
requirements:
id: \d+
sf_method: [GET]