In a form I have a field where the user have to enter the name, after this I have to update a markup with data from an external DB using the textfield as a parameter, How can I do this or even Is this posible?
PD: I am using autocomplete to show a list of users when the user is writing in the field. Thanks.
<?php /*this part is in hook_form_alter*/ $form['submitted']['empleado']['#ajax'] = array( 'callback' => 'ajax_saldo_markup_callback', 'wrapper' => 'saldo-markup-reload', ); $form['submitted']['saldo']['#prefix'] = '<div id="saldo-markup-reload">'; $form['submitted']['saldo']['#suffix'] = '</div>'; $form['submitted']['saldo']['#markup'] = _busqueda_saldo_vacas($form, $form_state); /*this part is in hook_form_alter*/ function ajax_saldo_markup_callback($form, $form_state) { return $form['submitted']['saldo']; } function _busqueda_saldo_vacas(&$form, $form_state){ $username = $form_state['values']['submitted']['empleado']; /*DB Query's*/ foreach ($result as $row) { //At the end I get only one data $form['submitted']['saldo']['#markup'] = $row->Data; } } ?>
With this code It seems to work, with Devel, the property “#markup” changes, but is not displayed, if I change it to “#title”, it is displayed.