Jump to content

Recommended Posts

Posted

Quick one off question. 

 

How would one set the '$success' array that is referenced in message.pdt to provide the green 'info box'?

 

Input->setErrors() is used to set the $errors array for the red box. 

Posted

Basic code ^^ but I think wrong lol

 

 

 

{if  $success}
<div  class=green>{$success}</div>

{else}

<div class=red>{Input->setErrors();}</div>
{/if}
Posted

The view code is already there.. 

 

(cut from app/views/admin/default/message.pdt)

---

<section class="error_section">
<?php
// $success is an alias for $message
if (isset($success))
$message = $success;
 
if (isset($message)) {
?>
<article class="error_box">
---
 
I just want to be able to set '$success' for the view to display from my module widget.
 
Adding this code: 
 
$this->Input->setErrors(array('test' => array('info' => "An unknown error has occured" )));
 
In my module widget code, causes the red error box to pop up with the error message. 
 
I'm looking for the bit that would allow me to set a 'Success' message which appears in Green with a checkmark. (as per the code above)  and can be seen for example by adding a service to a user or Successfully updating the service entries or the like. 
Posted

If I recall correctly, the module does not have access to do this through AppController::setMessage(), which would be:

$this->setMessage("message", "Success!");

So you would need to fetch the message template yourself and set it in your widget template:

// Untested code to fetch the message template, set your success message, and set it as the variable $message in your template
$this->set("message", $this->partial("message", array('message' => "Success!")));

Then call it from your widget template:

echo $this->Html->ifSet($message);

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...