I’ve the next form.
$query = "SELECT name, tid FROM taxonomy_term_data WHERE vid=2 AND language = '$language_url';"; $result = db_query($query); foreach ($result as $row2) { $options2[$row2->tid] = t($row2->name); } $form['group_config']['municipios'] = array( '#type' => 'checkboxes', '#title' => t('Municipios'), '#options' => $options2, '#required' => TRUE, );
I do a query to take the differents taxonomy terms that I have.
I don’t know how to obtain the values that the user has selected and save into a field.
I’ve done the next code but It dosn’t work.
function anuncio_datos_usuario(&$form_state,$values){ $node = new stdClass(); $node->title = $values['titulo']; $node->type = $type; node_object_prepare($node); $node->language = $values['idioma']; $node->uid = $userid; $node->status = 0; //(1 or 0): published or not $node->promote = 0; //(1 or 0): promoted to front page $node->sticky = 0; if(count($values['municipios'])) foreach($values['municipios'] as $municipio){ if($municipio!=0){ $node->field_municipio[LANGUAGE_NONE][]['tid']= $municipio; } } $node = node_submit($node); // Prepare node for saving node_save($node);
How can I save all the selected values into the field?
Thank you.