tigrantv
3/26/2015 - 12:30 PM

Ginosi Snippets

Ginosi Snippets

/**
 * @param \Zend\Form\Form $form
 * @return bool|string
 */
private function parseFormMessage($form)
{
    if (is_array($form->getMessages())) {
        $errorMessage = '';

        foreach ($form->getMessages() as $title => $values) {
            $formElement = $form->getElements();
            $errorMessage .= $formElement[$title]->getLabel() . PHP_EOL;

            if (is_array($values)) {
                foreach ($values as $value) {
                    $errorMessage .= '<li>' . $value . '</li>';
                }
            } else {
                $errorMessage .= $values;
            }
        }

        return $errorMessage;
    } elseif(is_string($form->getMessages())) {
        return $form->getMessages();
    } else {
        return false;
    }
}
var_dump($select->getSqlString($this->adapter->platform));
exit;
/**
 * @var \Library\Authentication\BackofficeAuthenticationService $auth
 */
$auth = $this->getServiceLocator()->get('library_backoffice_auth');
$userId = $auth->getIdentity()->id;
$reservationUrl = $this->url()->fromRoute(
    'backoffice/default',
    [
        'controller' => 'booking',
        'action' => 'edit',
        'id' => 12345
    ]
);
public function ajaxAction()
{
    try {
        $request = $this->getRequest();

        if (!$request->isPost() || !$request->isXmlHttpRequest()) {
            throw new \Exception(TextConstants::AJAX_ONLY_POST_ERROR);
        }

        $postData = $request->getPost();

        // code here

        $result = [
            'status'  => 'success',
            'post'    => $postData,
        ];
    } catch (\Exception $e) {
        $result = [
            'status' => 'error',
            'title'  => TextConstants::SERVER_ERROR,
            'msg'    => $e->getMessage(),
            'debug'  => $e->getTraceAsString(),
        ];
    }

    return new JsonModel($result);
}
<span data-content="Popover Description Here" data-container="body" data-toggle="popover" data-placement="top" class="commented-text" data-animation="true" data-original-title="" title="">
    Label Here
</span>