A
A
Albert Tobacco2014-10-10 18:22:25
Drupal
Albert Tobacco, 2014-10-10 18:22:25

How to add a field to the registration form programmatically?

How to add a field to the registration form programmatically? Well and to keep this value?
I'm looking in the direction of hook_form_alter () but I don't understand how it works yet

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2014-10-14
@bighoc

function yourmodulename_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_register_form') {
        $form['newfield'] = array(
            '#type' => 'textfield',
            '#title' => t('Sample field')
        );
    }
}

But about saving - that's another question. Depends on where to save and in what form. It is possible to do a sheaf with fields what that at the created user. Specify the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question