I'm working on a project with Laravel 5.6 and Vue.js 2 that is costing me more than I thought.
I have read several articles and questions in this community and everywhere I have understood that it is normal to use components of Vue.js to pass values by default.
When using the Blade template engine to load a form, for example, we have the following form:
<form method="{{ action('Controlador@metodo', $modelo) }}">
<input
type="text"
name="propiedad1"
@if(old('propiedad1'))
value="{{ old('propiedad1') }}"
@elseif(isset($modelo) && $modelo->propiedad1)
value="{{ $modelo->propiedad1 }}"
@endif
v-model="propiedad1"
@focusout="miFuncion">
<input
type="text"
name="propiedad2"
@if(old('propiedad2'))
value="{{ old('propiedad2') }}"
@elseif(isset($modelo) && $modelo->propiedad2)
value="{{ $modelo->propiedad2 }}"
@endif
v-model="propiedad2">
</form>
Well, for logical reasons (I think) the above does not work because we are mixing values that are put in the field before the DOM is created with fields that are created later.
The "simple" solution is to create a component, register it and adapt it ... But is not there an easier solution?