mzambranaa
10/19/2017 - 8:04 AM

Modificar formularios con form_alter. Ejemplo formulario user login.

Modificar formularios con form_alter. Ejemplo formulario user login.

<?php 
function mfs_projecte_form_alter(&$form, &$form_state, $form_id) {
    global $user;

       // dsm($form_id);
         switch($form_id) {
        //		case 'page_node_form':
        //		if()
        case 'producto_node_form' :
            if (array_key_exists(7, $user -> roles)) {
                foreach ($form as $key => $value) {
                    if ($key == 'field_archivos_relacionados' or $key == 'field_adjuntos' or $key == 'actions' or !is_array($value) or (!strstr($key, 'field_') and $key != 'divisa_base' and $key != 'body' and $key != 'language' and $key != 'title')) {
                        continue;
                    }
                    //if(isset($value['#access']))
                    $form[$key]['#access'] = FALSE;

                }
            }
            break;
            
        case 'user_login' :
            $form['name']['#description'] = t("Enter your username");
            $form['pass']['#title'] = t("User password");
            $form['pass']['#description'] = t("Write the password assigned to your user name");
            drupal_set_title(t('Access institutions'));
            break;
            
        case 'webform_client_form_235' :
            if ($_GET['tipo'] == "Fondos de pensiones") {
                //dsm($nodes);
                $form['submitted']['operacion_1']['tipo_de_operacion_1']['#options'][1] = t("Contribution");
            }
            //dsm($form);
            break;
        default :
            break;
    }
}

?>