/** * GOOD PRACTICE FOR VIEWS: * * A view should only display data and should not access the methods of the calling controller. * A view can: * - use the content of PHP variables defined by the calling controller + action * - define PHP variables locally (be careful to not crush the PHP variables defined by the calling controller) * - use utility classes to do data formatting * - integrate other views * - contain client code for web browsers (html, css, javascript, etc...) * - be tested to display data without using any controller * A view MUST NOT: * - contain "$this" or "self", i.e. no direct reference to methods and properties of the calling controller! * - directly access to the context of the web application (variables $_GET, $_POST, $_SESSION, $GLOBALS, etc...), * because the calling controller is responsible for that! */ use PHPYAM\core\Core; ?> <h2>Choose your demo:</h2> <ul> <li><a href="<?php echo Core::url('form1', 'index'); ?> ">Form with field validation and resubmit control</a></li> <li><a href="<?php echo Core::url('form2', 'index'); ?> ">Form with field validation, Ajax submit and resubmit control</a></li> </ul>
value="Validate"> <div style="display: <?php echo $_logs !== '' ? 'block' : 'none'; ?> ;"> <div id="feedback-panel-id"><?php echo $_logs; ?> </div> </div> </form> <div style="position: fixed; bottom: 0;"> <a href="<?php echo Core::url(DEFAULT_CONTROLLER, DEFAULT_ACTION); ?> ">Go back to home page</a> </div> <script type="text/javascript"> $(document).ready(function() { // Initialization of the form validation plugin $("#form-id").validate(); // Attach a submit handler to the form $("#submit-button-id").click(function(event) { // Stop form from submitting normally event.preventDefault();
/** * (non-PHPdoc) * * @see \PHPYAM\core\interfaces\IRouter::forward() */ public final function forward($urlController, $urlAction, array $urlParameters = array(), $clearOutputBuffersBeforeRedirect = true) { if ($clearOutputBuffersBeforeRedirect) { // We empty all buffers. while (ob_get_level() > 0) { ob_end_clean(); } } // We check that the header() statements have been taken into account, // which is only possible if the HTTP headers have not been sent yet. Assert::isFalse(headers_sent(), StringUtils::gettext('HTTP headers have already been sent.')); header('location:' . Core::url($urlController, $urlAction, $urlParameters)); }