I want to make a form that is constantly reviewed by a controller, but by means of an ajax, that is, my field is the user's, and I want to validate if the user already exists, but what I have said to me:
Notice (8): Undefined variable: ajax [APP/View/Pages/full_client.ctp, line 105]
Your client informatio was save
Call to a member function observeField() on null
Error: An Internal Error Has Occurred.
And so far I have this:
<!-- multistep form -->
<?php
echo $this->Form->create('Client', array('class' => '', 'id' => 'msform'));
?>
<!-- progressbar -->
<ul id="progressbar">
<li class="active">Necesidad del cliente</li>
<li>Informacion Personal</li>
<li>finish</li>
</ul>
<!-- fieldsets -->
<fieldset>
<h2 class="fs-title">Hablanos sobre tu necesidad</h2>
<h3 class="fs-subtitle">Requerimiento</h3>
<div class="DontGrowWidth">
<?php
echo $this->Form->input('informacion', array('placeholder' => 'Cuentanos sobre el problema que tienes', 'label' => false,
'class' => 'validador txtInformacion'));
?>
</div>
<input type="button" name="next" class="next action-button btn-nextOne" value="Next" hidden/>
</fieldset>
<fieldset>
<h2 class="fs-title">Hablanos sobre tu empresa</h2>
<h3 class="fs-subtitle">Negocio</h3>
<?php
echo $this->Form->input('empresa', array('label' => false, 'placeholder' => 'Dinos el nombre de tu empresa',
'class' => 'validador txtEmpresa'));
echo $this->Form->input('telefono', array('label' => false, 'placeholder' => 'Dano el telefono de tu empresa',
'class' => 'validador txtTelefono'));
echo $this->Form->input('direccion', array('label' => false, 'placeholder' => 'Danos la direccion de tu empresa',
'class' => 'validador txtDireccion'));
?>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="next" class="next action-button btn-nextTwo" value="Next" hidden/>
</fieldset>
<fieldset>
<h2 class="fs-title">Hablanos sobre ti</h2>
<h3 class="fs-subtitle">Cliente</h3>
<?php
echo $this->Form->input('cliente', array('label' => false, 'placeholder' => 'Dinos como te llamas',
'class' => 'validador txtCliente'));
echo $this->Form->input('horario', array('label' => false, 'placeholder' => 'Dinos en que horario podemos contactarte',
'class' => 'validador txtHorario'));
echo $this->Form->input('usuario', array('label' => false, 'placeholder' => 'Ingresa el nombre de usuario que elijas',
'class' => 'validador txtUsuario'));
echo $this->Form->input('clave', array('type' => 'password', 'label' => false,
'placeholder' => 'Ingresa en contraseña para el ingreso',
'class' => 'validador txtClave'));
?>
<div id='captcha' class="g-recaptcha" data-sitekey="6LfukUYUAAAAABRE_7Ap1RJOG8tpmUJOJNnFDeo1" data-callback='recaptcha_callback'></div>
<input type="button" name="previous" class="previous action-button" value="Previous" />
<div class="divSubmit" hidden>
<a href="#" class="aSubmit">submit</a>
<a class="aSubmit loading" href="#">loading</a>
<svg viewBox="0 0 240 220">
<rect id="middle" x="20" y="100" width="200" height="60" rx="30"></rect>
<path id="top" d="
M 60,100
L 50,100
C 33.4357078,100 20,113.427814 20,130
L 20,130
C 20,146.568541 33.4331197,160 50,160
L190,160
C206.570288,160 220,146.572314 220,130
L220,100
C220,-60 180, 80 160,100
C140,120 100,160 100,160
"></path>
<path id="bottom" d="
M180,160
L190,160
C206.564295,160 220,146.572186 220,130
L220,130
C220,113.431458 206.56688,100 190,100
L 50,100
C33.4297125,100 20,113.435296 20,130
C20,130 20,120 20,140
C20,220 180,200 120,140
C100,120 80,100 80,100
"></path>
</svg>
<a class="aSubmit feedback" href="#"></a>
</div>
</fieldset>
<?php echo $this->Form->end(); ?>
<?php
echo $ajax->observeField( 'ClientUsuario',
array(
'url' => array( 'action' => 'validar' ),
'frequency' => 0.2,
)
);
?>
<!--echo $this->Form->input('id', array('type' => 'hidden'));-->
But I do not know how to do things, for example? in the controller of that form I create a function called validate? and if so, how do I change the color of the input from there?