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
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
On 4 feb. 2015, at 08:35, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
Thank you Eric for replying, Like I said, this started happening after I renamed the field. Could this be why? On 4 February 2015 at 10:52, Erik Stielstra <info@erikstielstra.nl> wrote:
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
On 4 feb. 2015, at 08:35, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
-- mto
On 4 feb. 2015, at 10:15, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
Not the field label, field name. On 4 February 2015 at 13:15, Erik Stielstra <info@erikstielstra.nl> wrote:
On 4 feb. 2015, at 10:15, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
This is what happens when I re-install the module: https://dl.dropboxusercontent.com/u/11918318/Screenshot%20from%202015-02-05%... On 4 February 2015 at 13:16, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
Not the field label, field name.
On 4 February 2015 at 13:15, Erik Stielstra <info@erikstielstra.nl> wrote:
On 4 feb. 2015, at 10:15, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
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
On 5 feb. 2015, at 12:51, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
This is what happens when I re-install the module:
https://dl.dropboxusercontent.com/u/11918318/Screenshot%20from%202015-02-05%...
On 4 February 2015 at 13:16, Muzaffer Tolga Ozses <tolga@ozses.net> wrote: Not the field label, field name.
On 4 February 2015 at 13:15, Erik Stielstra <info@erikstielstra.nl> wrote:
On 4 feb. 2015, at 10:15, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
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". On 5 February 2015 at 14:02, Erik Stielstra <info@erikstielstra.nl> wrote:
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
On 5 feb. 2015, at 12:51, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
This is what happens when I re-install the module:
https://dl.dropboxusercontent.com/u/11918318/Screenshot%20from%202015-02-05%...
On 4 February 2015 at 13:16, Muzaffer Tolga Ozses <tolga@ozses.net>
wrote:
Not the field label, field name.
On 4 February 2015 at 13:15, Erik Stielstra <info@erikstielstra.nl> wrote:
On 4 feb. 2015, at 10:15, Muzaffer Tolga Ozses <tolga@ozses.net> wrote:
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
-- mto
participants (2)
-
Erik Stielstra -
Muzaffer Tolga Ozses