Search code examples
phpmodel-view-controllerprado

Problems passing data to view using PRADO


I've been given a website to maintain. The website is using PRADO framework and I had to do some minor changes. There were no problems with the HTML and CSS changes, but now I have to pass some data from a page to a view. I've tried using:

$this->HomeCalendar2->DataSource = $result['data'];
$this->HomeCalendar2->dataBind();

but it says Component property 'Home.HomeCalendar2' is not defined.

Above my code there is the following code:

$this->HomeCalendar->DataSource = $result;
$this->HomeCalendar->dataBind();

and it works perfectly fine and I can't see where is the definition of HomeCalendar. Any help will be appreciated.

P.S: I've never worked with PRADO before.


Solution

  • This question is quite old now, hope you already solved it.

    Using DataSource means that there must be in your template (.page or .tpl) a TDataBoundControl component like the folowwing (using TRepeater for example)

    <com:TRepeater ID="HomeCalendar">
    <!--- [ properties like ItemTemplate here and it contents ] --->
    </com:TRepeater>
    

    Subclasses of TDataBoundControl are for component needing to loop results, (sorts of for or foreach somehow). If you juste need to pass a signle result to the view you can use a component like TPanel/TActivePanel, TLiteral, etc. or simply use the expression tag.

    Examples :

    Expression tag :

    Php :

    <?php
    $this->myvalue = 'Hello World!';
    

    Template :

    <h1><%= $this->myvalue %></h1>
    

    Or another solution:

    Template :

    <com:TLiteral ID="MyLiteral" />
    

    PHP :

    <?php
    $this->MyLiteral->getControls()->add('<h1>Hello world !</h1>');