Posted by Ata ul Mustafa on July 4, 2011 at 6:52am
2 followers
Jump to:
| Project: | CAPTCHA |
| Version: | 6.x-2.2 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | captcha, captcha issue, captcha requests, captcha tab index |
Issue Summary
I am using captcha on my form.I want to apply tab index on captcha field but cant able to make it happen. I already tried to apply on theming the form and also in hook_form_alter but cant succeeded.I used the code like this and tried to assign it a value:
$form['captcha']['captcha_sid']['captcha_widgets']['captcha_response']['#attributes'] = array('tabindex' => 19);
Always its attributes array is empty when i check its source.I also googled it but cant find any solution. Thanks in advance.
Comments
#1
#2
With a form_alter hook you're in the good direction
$form['captcha']['captcha_sid']['captcha_widgets']['captcha_response']['#attributes'] = array('tabindex' => 19);where did this "path" come from?
Depending, on the form you want to tweak, it should be more something
$form['captcha']['captcha_response']['#attributes'] = array('tabindex' => 19);#3
Thanks for responding.
Actually, I am appointing the captcha textfield in which we write a code given in captcha. and i am printing this in hook_form_alter and then applying tabindex to this field but it doesnot work for me.It is in this hierarchy which i mentioned in previous post:
$form['captcha']['captcha_sid']['captcha_widgets']['captcha_response']['#attributes'] = array('tabindex' => 19);
But not the one you mentioned soxofaan.
Later on i done it through javascript.My javascript working is like this:
I called a javascript mehod on that textfield(not captcha), after which control will moveover to captcha textfield. Code is like this which i entered in its attribute property.
'#attributes' => array('onblur' => 'javascript:focus_on_captcha();')
And in this function i just put focus on that captcha field by pointing its id.
Any other way to do this? Suggestions will be warmly welcomed.
Ata
#4
I still don't understan how you get that hierarchy.
For example, 'captcha_sid' should be an end leave in your form (it is a hidden form element), it should not be a parent of the 'captcha_response' text field
#5
When i print $form, i got hierarchy like this:
Array(
// Other Information
[captcha] => Array
(
[#type] => captcha
[#captcha_type] => image_captcha/Image
[#weight] => 29.9
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => captcha
)
[#array_parents] => Array
(
[0] => captcha
)
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#required] =>
[#input] => 1
[#process] => Array
(
[0] => captcha_process
)
[#default_value] =>
[#captcha_admin_mode] =>
[#captcha_validate] => captcha_validate_case_insensitive_ignore_spaces
[#name] => captcha
[#id] => edit-captcha
[#value] =>
[captcha_sid] => Array
(
[#type] => hidden
[#value] => 2707
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => captcha_sid
)
[#array_parents] => Array
(
[0] => captcha
[1] => captcha_sid
)
[#weight] => 0
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#required] =>
[#input] => 1
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => captcha_sid
[#id] => edit-captcha-sid
[#defaults_loaded] => 1
[#sorted] => 1
)
[#captcha_info] => Array
(
[form_id] => user_register
[module] => image_captcha
[type] => Image
[captcha_sid] => 2707
[solution] => HEWd
)
[captcha_widgets] => Array
(
[captcha_image] => Array
(
[#type] => markup
[#value] =>
[#weight] => -2
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => captcha_image
)
[#array_parents] => Array
(
[0] => captcha
[1] => captcha_widgets
[2] => captcha_image
)
[#processed] =>
[#description] =>
[#attributes] => Array
(
)
[#required] =>
[#prefix] =>
[#suffix] =>
[#defaults_loaded] => 1
[#sorted] => 1
)
[captcha_response] => Array
(
[#type] => textfield
[#title] => What code is in the image?
[#description] => Enter the characters shown in the image.
[#weight] => 0
[#required] => 1
[#size] => 15
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => captcha_response
)
[#array_parents] => Array
(
[0] => captcha
[1] => captcha_widgets
[2] => captcha_response
)
[#processed] => 1
[#attributes] => Array
(
)
[#input] => 1
[#maxlength] => 128
[#autocomplete_path] =>
[#process] => Array
(
[0] => form_expand_ahah
[1] => ckeditor_process_input
[2] => i18n_textfield_process
)
[#name] => captcha_response
[#id] => edit-captcha-response
[#value] =>
[#defaults_loaded] => 1
[#sorted] => 1
)
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => captcha_widgets
)
[#array_parents] => Array
(
[0] => captcha
[1] => captcha_widgets
)
[#weight] => 0.001
[#processed] =>
[#defaults_loaded] => 1
)
[#element_validate] => Array
(
[0] => captcha_validate
)
[#pre_render] => Array
(
[0] => captcha_pre_render_process
)
[#defaults_loaded] => 1
[#sorted] => 1
)
)
This is what i got.