CodeIgniter Forums
Implementing a new library - moving data between controller and view. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Implementing a new library - moving data between controller and view. (/showthread.php?tid=21483)



Implementing a new library - moving data between controller and view. - El Forum - 08-11-2009

[eluser]Unknown[/eluser]
I believe I have this question because I am weak in PHP OOP, a beginner in Codeigniter or a combination :-S

I am having a problem understanding how to share an object between a view and controller.

I am implementing a date/time form field class that works in plain old php/html. It uses pulldowns to set YMD and HH:MM fields, takes care of some conversions and parsing.

In the view I have:
Code:
$concert_datetime = new Datetime_field();
Then the view displays using:
Code:
echo $concert_datetime->get_select_years("ldigit", "2009", "2012", "year");
echo $concert_datetime->get_select_months(1, "sword", "month");
echo $concert_datetime->get_select_days(1, "day");
echo $concert_datetime->get_select_hours(1, 12, "hour")."<b>:</b>";
echo $concert_datetime->get_select_minutes(1, "0", "min")."<b>:</b>";
echo $concert_datetime->get_select_ampm();
Currently there is no code to manipulate the object in the controller except:
Code:
$justEnteredDateTime = $concert_datetime->get_timestamp_entered();
Execution of this results in an undefined variable error.

Do I need a different form of reference?
Do I need to move the object declaration to the controller?
Then how do I refer to it in the view?

I would very much like to rtfm or rtft(utorial) or w(atch)tft but I have not yet found them :red: