Discussion:
Field invisible
(too old to reply)
Muzaffer Tolga Ozses
2015-02-04 07:35:32 UTC
Permalink
Hi,

I've got the below code. After enabling the module, the field is seen
disabled in /admin/config/people/accounts/display/full. Furthermore, even
if I enable it, it is not on user account page, even though it is visible
in dpm() output. This started happening after I changed the field name.

<?php
/**
* Implements hook_install().
*/
function tckn_kontrol_install() {
$field = array(
'field_name' => 'field_tckn',
'type' => 'text',
'settings' => array(
'max_length' => 11,
),
);
$instance = array(
'field_name' => 'field_tckn',
'entity_type' => 'user',
'bundle' => 'user',
'required' => TRUE,
'label' => t('TCKN'),
'description' => t('Enter your TCKN.'),
'settings' => array(
'user_register_form' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'text_textfield',
),
),
'widget' => array(
'settings' => array(
'size' => 12,
),
),
);
field_create_field($field);
field_create_instance($instance);
}
function tckn_kontrol_uninstall() {
$instance = array(
'field_name' => 'field_tckn',
'bundle' => 'user',
);
field_delete_field($instance['field_name']);
}
​Thank you in advance for replying.​
--
mto
Erik Stielstra
2015-02-04 08:52:17 UTC
Permalink
Hi mto,

I can not reproduce your problem. I copied the code in hello.install, renamed the function to hello_install(), enabled the module and the field was visible in the account form and the user page. Try you code again in on a D7 core, out of the box. Is must be some interaction with other code or styling.

Regards,
Erik Stielstra
Hi,
I've got the below code. After enabling the module, the field is seen disabled in /admin/config/people/accounts/display/full. Furthermore, even if I enable it, it is not on user account page, even though it is visible in dpm() output. This started happening after I changed the field name.
<?php
/**
* Implements hook_install().
*/
function tckn_kontrol_install() {
$field = array(
'field_name' => 'field_tckn',
'type' => 'text',
'settings' => array(
'max_length' => 11,
),
);
$instance = array(
'field_name' => 'field_tckn',
'entity_type' => 'user',
'bundle' => 'user',
'required' => TRUE,
'label' => t('TCKN'),
'description' => t('Enter your TCKN.'),
'settings' => array(
'user_register_form' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'text_textfield',
),
),
'widget' => array(
'settings' => array(
'size' => 12,
),
),
);
field_create_field($field);
field_create_instance($instance);
}
function tckn_kontrol_uninstall() {
$instance = array(
'field_name' => 'field_tckn',
'bundle' => 'user',
);
field_delete_field($instance['field_name']);
}
​Thank you in advance for replying.​
--
mto
Muzaffer Tolga Ozses
2015-02-04 09:15:31 UTC
Permalink
Thank you Eric for replying,

Like I said, this started happening after I renamed the field. Could this
be why?
Post by Erik Stielstra
Hi mto,
I can not reproduce your problem. I copied the code in hello.install,
renamed the function to hello_install(), enabled the module and the field
was visible in the account form and the user page. Try you code again in on
a D7 core, out of the box. Is must be some interaction with other code or
styling.
Regards,
Erik Stielstra
Post by Muzaffer Tolga Ozses
Hi,
I've got the below code. After enabling the module, the field is seen
disabled in /admin/config/people/accounts/display/full. Furthermore, even
if I enable it, it is not on user account page, even though it is visible
in dpm() output. This started happening after I changed the field name.
Post by Muzaffer Tolga Ozses
<?php
/**
* Implements hook_install().
*/
function tckn_kontrol_install() {
$field = array(
'field_name' => 'field_tckn',
'type' => 'text',
'settings' => array(
'max_length' => 11,
),
);
$instance = array(
'field_name' => 'field_tckn',
'entity_type' => 'user',
'bundle' => 'user',
'required' => TRUE,
'label' => t('TCKN'),
'description' => t('Enter your TCKN.'),
'settings' => array(
'user_register_form' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'text_textfield',
),
),
'widget' => array(
'settings' => array(
'size' => 12,
),
),
);
field_create_field($field);
field_create_instance($instance);
}
function tckn_kontrol_uninstall() {
$instance = array(
'field_name' => 'field_tckn',
'bundle' => 'user',
);
field_delete_field($instance['field_name']);
}
​Thank you in advance for replying.​
--
mto
--
mto
Erik Stielstra
2015-02-04 11:15:31 UTC
Permalink
Post by Muzaffer Tolga Ozses
Thank you Eric for replying,
Like I said, this started happening after I renamed the field. Could this be why?
I don’t know. You should not rename a field (change machine name) unless you know exactly what you are doing. Just create a new one. Changing the field label should not have this effect.


Erik Stielstra
Muzaffer Tolga Ozses
2015-02-04 11:16:24 UTC
Permalink
Not the field label, field name.
Post by Muzaffer Tolga Ozses
Post by Muzaffer Tolga Ozses
Thank you Eric for replying,
Like I said, this started happening after I renamed the field. Could
this be why?
I don’t know. You should not rename a field (change machine name) unless
you know exactly what you are doing. Just create a new one. Changing the
field label should not have this effect.
Erik Stielstra
--
mto
Muzaffer Tolga Ozses
2015-02-05 11:51:38 UTC
Permalink
This is what happens when I re-install the module:

Loading Image...
Post by Muzaffer Tolga Ozses
Not the field label, field name.
Post by Muzaffer Tolga Ozses
Post by Muzaffer Tolga Ozses
Thank you Eric for replying,
Like I said, this started happening after I renamed the field. Could
this be why?
I don’t know. You should not rename a field (change machine name) unless
you know exactly what you are doing. Just create a new one. Changing the
field label should not have this effect.
Erik Stielstra
--
mto
--
mto
Erik Stielstra
2015-02-05 12:02:31 UTC
Permalink
As I said "I can not reproduce your problem” and what I can’t reproduce I can not fix.

I would go looking for working examples. You can try the examples module. It has a.o. an entity- and a field example module. You can also try to add a field via the interface and then export its code using features. That will give you some PHP-code that should almost be what you need to create a field programatically.

Erik Stielstra
Post by Muzaffer Tolga Ozses
https://dl.dropboxusercontent.com/u/11918318/Screenshot%20from%202015-02-05%2013%3A47%3A42.png
Not the field label, field name.
Post by Muzaffer Tolga Ozses
Thank you Eric for replying,
Like I said, this started happening after I renamed the field. Could this be why?
I don’t know. You should not rename a field (change machine name) unless you know exactly what you are doing. Just create a new one. Changing the field label should not have this effect.
Erik Stielstra
--
mto
--
mto
Muzaffer Tolga Ozses
2015-02-05 12:12:11 UTC
Permalink
Okay, I got the issue; it was #access. I must have mis-read API docs where
I thought #access meant "hide it from those with no access".
As I said "I can not reproduce your problem” and what I can’t reproduce I
can not fix.
I would go looking for working examples. You can try the examples module.
It has a.o. an entity- and a field example module. You can also try to add
a field via the interface and then export its code using features. That
will give you some PHP-code that should almost be what you need to create a
field programatically.
Erik Stielstra
https://dl.dropboxusercontent.com/u/11918318/Screenshot%20from%202015-02-05%2013%3A47%3A42.png
Post by Muzaffer Tolga Ozses
Not the field label, field name.
Post by Muzaffer Tolga Ozses
Thank you Eric for replying,
Like I said, this started happening after I renamed the field. Could
this be why?
Post by Muzaffer Tolga Ozses
I don’t know. You should not rename a field (change machine name) unless
you know exactly what you are doing. Just create a new one. Changing the
field label should not have this effect.
Post by Muzaffer Tolga Ozses
Erik Stielstra
--
mto
--
mto
--
mto
Continue reading on narkive:
Loading...