I am in View from Seleccion Model.
I did create a button for Add for Antecedentes Model (in the seleccion view).
Antecedentes Model has Seleccion_id input.
I want to set the value of Antecendete Seleccion_id = Seleccion id wich I pickup the button.
Is this in your add or edit page? In the edit, you shouldn’t need to set a default at all, as it should be there automatically from the entity you’re editing. In the add, do you want to set a default?
Hi.
Yes is the add action for seleccionAntecendestes that was called from the view of a record in seleccion.
seleccionAntecedentes stores the seleccion_id, that is what i want to store deffault.
Ah, gotcha. In your controller, you can use something like $seleccione_id = $this->request->getQuery('seleccione_id');
to get the query parameter, and then $this->set(compact('seleccione_id'));
to send that variable to the view. Then just 'default' => $seleccione_id.
Note that if you don’t want them to be able to change the value, then a hidden field instead of an input control would be the way to go.
You’ve skipped some code from your controller here. There’s presumably a bit that checks if it’s a post, and does all of this stuff only in that case? You want the getQuery and set lines to be before that, so they happen when the empty form is loaded, not just when it’s posted.