Zum Inhalt springen

Controller Action mit optionalen Parametern

Erstellt am 26. September 2011 · 1 Antwort · letzte Antwort am 27. September 2011

Tags: Frage

Willi ·

Hallo,

kann mir jemand verraten wie ich eine Controller-Action mit optionalen Parametern gestalte?

Im Moment habe ich diesen Methodenkopf

	 /**
	 * Displays all Seminars
	 *
	 * @param string $search
	 * @param int $catId
	 * @param int $tutorId
	 * @return void
	 */
	public function filteredListAction($search, $catId, $tutorId){ ...

Der gibt mir allerdings folgenden Fehler:

An error occurred while trying to call Tx_Seminar_Controller_SeminarController->filteredListAction(). Error: Required property 'catId' does not exist. Error: Required property 'tutorId' does not exist.

Wenn ich die URL aufrufe:

index.php?id=47&tx_seminar_seminarlistfilter[search]=hussel

Und vielleicht noch eine kleine Grundsatzfrage, orientiert sich die Doc-Comment Funktionalität 1:1 an der JavaDoc Noation?

jank ·

Hallo Willi,
das geht indem du den optionalen Parameter vorbelegst.
z.B. mut NULL

/**
	 * action create
	 *
	 * @param $newXY
	 * @param $parentXY
	 * @return void
	 */
public function createAction(Tx_MyExt_Domain_Model_XY $newXY, Tx_MyExt_Domain_Model_XY $parentXY = NULL) {
}