} else {
$this->_datas->refreshForm($form); // Respond with validation errors
+ $this->_datas->addAction('eval', 'displayErrors()');
}
}
public function init() {
parent::init();
+ $first_name = new Zend_Form_Element_Text('first_name');
+ $first_name->setLabel(__('Prénom'));
+ $this->addElement($first_name);
+
$last_name = new Zend_Form_Element_Text('last_name');
- $last_name->setLabel(__('Votre nom'));
+ $last_name->setLabel(__('Nom'));
$last_name->setRequired(true);
$last_name->addErrorMessage(__('Votre nom est obligatoire'));
$this->addElement($last_name);
- $first_name = new Zend_Form_Element_Text('first_name');
- $first_name->setLabel(__('Prénom'));
- $first_name->setRequired(false);
- $first_name->addErrorMessage(__('Votre prénom est obligatoire'));
- $this->addElement($first_name);
-
$company = new Zend_Form_Element_Text('company');
$company->setLabel(__('Nom de la société'));
$company->setRequired(true);
- $company->addErrorMessage(__('Champ obligatoire'));
+ $company->addErrorMessage(__('Votre nom de la société est obligatoire'));
$this->addElement($company);
$contact_type = new Zend_Form_Element_Select('contact_type');
$phone = new Zend_Form_Element_Text('phone');
$phone->setLabel(__('Téléphone'));
- $phone->setRequired(false);
- $phone->addErrorMessage(__('Champ obligatoire'));
$this->addElement($phone);
$comments = new Zend_Form_Element_Textarea('comments');
$res .= '<div class="text col-2">';
$res .= '<h1 class="title">'. nl2br($this->option('quote_heading')) .'</h1>';
$res .= $this->markupDotclear($this->option('quote_description'));
- $res .= '</div>'; // .col-2
+ $res .= '</div>'; // .text
$res .= '<div class="form col-4">';
$form = new Fluidbook_Form_RequestQuote();
$res .= $form;
- $res .= '</div>'; // .col-4
+ $res .= '<div class="validation-messages"></div>';
+ $res .= '</div>'; // .form
$res .= '</div>'; // .request-quote
return $res;
--- /dev/null
+function displayErrors() {
+
+ var errors = [];
+
+ // Collect errors from the form
+ $('.errormessage').each(function () {
+ errors.push($(this).text());
+
+ $('.validation-messages').html(errors.join('<br>')).fadeIn(500, function() {
+ setTimeout(function() {
+ $('.validation-messages').fadeOut(500);
+ }, 3000);
+ });
+ });
+}
\ No newline at end of file
@color-footer-bg-secondary: #161e26;
@color-green: #8aab41;
@color-header-grey: #2a3743;
+@color-error: #c91818;
//-- Content and breakpoints
@mobile-breakpoint: 1024px;
padding-right: 30px;
}
+ .form {
+ position: relative;
+ }
+
.zend_form {
display: flex;
flex-wrap: wrap;
}
}
+ // Validation Error Messages
+ .errormessage {
+ display: none; // Will be displayed elsewhere
+ }
+
+ .error dd {
+ position: relative;
+
+ &:after {
+ content: '';
+ position: absolute;
+ left: 0;
+ bottom: 1px;
+ width: 100%;
+ height: 5px;
+ background-color: @color-error;
+ }
+
+ input[type="text"], input[type="email"], select {
+ border-color: @color-text;
+ border-bottom-color: @color-error;
+ }
+
+ }
+
+ .validation-messages {
+ padding: 22px 50px;
+ background-color: #242424;
+ position: absolute;
+ bottom: 10px;
+ left: 50%;
+ transform: translateX(-50%);
+ color:#fff;
+ font-size: 16px;
+ text-align: center;
+ border-radius: 200px;
+ z-index: 1000;
+ pointer-events: none;
+ display: none;
+ }
+
}
\ No newline at end of file