drupal-fields

Custom Drupal 7 Field only saves the first character

走远了吗. 提交于 2020-01-01 12:26:08
问题 I'm essentially trying to create my first field type module using the new Drupal 7 Field API. I've managed to get it to display correctly in the "edit" view. However, when I try to save some data it only saves the first character. Here's the module: <?php function youtubefield_field_info() { return array( 'youtubefield_video' => array( 'label' => t('Youtube video'), 'description' => t('This field stores a youtube video ID and displays the video associated with it'), 'settings' => array( 'max

How to add new fields to user profile in Drupal 7 programmatically

爱⌒轻易说出口 提交于 2019-12-23 04:45:18
问题 I want to develop a module that add fields to user profile in drupal 7, like phone number and CV ... and I don't know how to do that (using Database or using fields API) pls help me. Any clear tutorials will be appreciated. 回答1: Try to follow the following code $myField_name = "NEW_FIELD_NAME"; if(!field_info_field($myField_name)) // check if the field already exists. { $field = array( 'field_name' => $myField_name, 'type' => 'text', ); field_create_field($field); $field_instance = array(

hook_user(): inserting extra field into database not just form

十年热恋 提交于 2019-12-07 15:31:11
问题 I can add an extra field to the registration. What I need to know is what step do I need to take to then grab that input and insert it into the user table of drupal. The code below is in my module this adds just a field to the form, but when its submitted it doesnt do anything with the data. function perscriptions_user($op, &$edit, &$account, $category = NULL){ if ($op == 'register') { $form['surgery_address'] = array ( '#type' => 'textarea', '#title' => t('Surgery Address'), '#required' =>

hook_user(): inserting extra field into database not just form

陌路散爱 提交于 2019-12-05 19:56:56
I can add an extra field to the registration. What I need to know is what step do I need to take to then grab that input and insert it into the user table of drupal. The code below is in my module this adds just a field to the form, but when its submitted it doesnt do anything with the data. function perscriptions_user($op, &$edit, &$account, $category = NULL){ if ($op == 'register') { $form['surgery_address'] = array ( '#type' => 'textarea', '#title' => t('Surgery Address'), '#required' => TRUE, ); return $form; } if ($op == 'update') { // … } } As reported in hook_user() documentation : $op

Custom Drupal 7 Field only saves the first character

江枫思渺然 提交于 2019-12-04 12:48:00
I'm essentially trying to create my first field type module using the new Drupal 7 Field API. I've managed to get it to display correctly in the "edit" view. However, when I try to save some data it only saves the first character. Here's the module: <?php function youtubefield_field_info() { return array( 'youtubefield_video' => array( 'label' => t('Youtube video'), 'description' => t('This field stores a youtube video ID and displays the video associated with it'), 'settings' => array( 'max_length' => 11, ), 'instance_settings' => array( 'text_processing' => false, ), 'default_widget' =>