lundi 16 octobre 2017

¿How to capture a value from a select in the login view and declare it global?

I can not manage to capture a value from a combo from my login view, to use it in the user registry. I am trying to use the HTTP routes methods as described in the laravel 5.1 documentation, but without any success.

Here is the combo cboFranquicias in the view of login.blade.php, whose value I want to capture to pass it to the user registry view:

<form method="POST" action="">
    {!! csrf_field() !!}
    <div class="row margin">
      <div class="input-field col s12">
    <i class="mdi-social-person-outline prefix"></i>
    <input type="text" name="usuario" id="usuario" value="" required>
    <label for="usuario" class="center-align">Usuario</label>
    </div>
  </div>
  <div class="row margin">
    <div class="input-field col s12">
      <i class="mdi-action-lock-outline prefix"></i>
      <input type="password" name="password" id="password" required>
      <label for="password">Contraseña</label>
    </div>
  </div>

 <!--COMBO TO LIST FRANQUICIAS -->
   <br><div class="input-field col m12 s12" style="right:-1%">
    {!!Form::select('Franquicias', $combo_franquicias, null, ['placeholder'=>'--Selecciona--','id'=>'cboFranquicias','name'=>'cboFranquicias'])!!} 
    {!!Form::label('Franquicias')!!}
  </div><!--END COMBO -->


  <div class="row">
      <!--ACOMODADO TAMAÑO DEl BOTON ENTRAR-->
    <div class="input-field col s12 m12">
      <button type="submit" class="btn waves-effect waves-light col s12 m12 19">Entrar</button>
    </div>
  </div>
</form>

Later, in routes.php, I declare a route that takes by the method the values entered in the login, to the function that will return the user registry view:

Route::get('registrar', 'Auth\AuthController@VistaRegistraUsuario'); Route::post('auth/login', 'Auth\AuthController@VistaRegistraUsuario');

And here is the function that returns to the user registry view in the AuthController.php file:

`public function VistaRegistraUsuario(Request $request)
  {
 $id_franquicia = $request->input('cboFranquicias');
 //dd($id_franquicia);
 $cargos = cargos_usuarios::lists('descripcion', 'id');

 return view('auth.register', compact('cargos','id_franquicia'));
  }`

However, the value never reaches the user registry view, which should pass to fill my hidden input in that view register.blade.php:

{!!Form::input('Id_franquicia', $id_franquicia, null, ['type'=>'hidden','name'=>'id_franquicia', 'id'=>'id_franquicia'])!!}

How do I capture the value of the franquicias combo in the login view and save it to a global variable, to pass that value to the user registration view?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire