Show message on add page instead of form

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
cosmic_goo
User
Posts: 60

Show message on add page instead of form

Post by cosmic_goo »

Hi,

I want to be able to stop adding a record (and display a message) to a page if an option in the database is selected.

So say one of my pages is http://localhost/test/pageadd and I have another table with the database record saying whether that page was accessible or not.

Which server even should I use (i.e. Page_Load / Page_Render etc) to check the "access flag" and if disabled show a message and if not continue to load the rest of the Add Page form?

Thanks


mobhar
User
Posts: 11922

Post by mobhar »

You may use Page_Render server event that belongs to the Add Page.


cosmic_goo
User
Posts: 60

Post by cosmic_goo »

i actually want to use Page_DataRendering as I want the rest of the page to load, but I just want the form to not be displayed. how do I change the visibility of the whole form?

// Page Data Rendering event
function Page_DataRendering(&$header)
{

    $hideForm = TRUE;
    if ($shedhideFormClosed) {
        $this->FORM_NAME->Visible = false; // Hide the entire form
    }

}

arbei
User
Posts: 9862

Post by arbei »

There is no $this->FORM_NAME, the form object is a JavaScript object, not PHP object. So you may use Startup Script to hide the form, e.g. if table name is "cars", $("#fcarsadd").hide().


cosmic_goo
User
Posts: 60

Post by cosmic_goo »

Thanks... I ended up hiding the form as well as the individual fields:

        $hideForm= TRUE;

        if ($hideForm) {
            echo '<style>#form_id { display: none !important; }</style>';
            $this->field_1->Visible = false; // Hide field
            $this->field_2->Visible = false; 
            $this->field_3->Visible = false; 
            [...]		
        }

Post Reply