Closed (fixed)
Project:
module
Component:
Code
Priority:
Critical
Category:
Plan
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Dec 2019 at 08:49 UTC
Updated:
14 Feb 2020 at 16:34 UTC
Jump to comment: Most recent
I want to add one or two fields in user register form, for that i have made alter hook to inject field by the below code:
function kaz_module_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
$form['account']['bike_reg_file'] = array(
'#type' => 'file',
'#title' => t('Enter bike registration file'),
'#default_value' => '',
'#description' => t('Help text goes here'),
);
$form['account']['sex'] = array(
'#type' => 'textfield',
'#title' => t('Enter sex'),
'#default_value' => '',
'#description' => t('Type male or female'),
);
$form['actions']['submit']['#submit'][] = 'kaz_module_user_form_submit_handler';
return $form;
}
.....................
But after that in submit function i am not able to get those fields value, see my code below:
function kaz_module_user_form_submit_handler(array &$form, FormStateInterface $form_state)
{
$bike_reg_file = $form_state->getValue('bike_reg_file');
$sex = $form_state->getValue('sex');
echo '<pre>';
var_dump($bike_reg_file);
var_dump($sex);
echo '</pre>';
die();
}
How can i get that value and then how can i save the value for that registered user's?
Do i need to plan in another way to achieve this goal?
Also here sex field is giving value which was text field, but bike_reg_file is giving me blank string, where it was a file field.
Thanks
Comments
Comment #2
ashique12009 commentedComment #3
ashique12009 commentedComment #4
ashique12009 commentedComment #5
rambabburi commented