Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I need to initialize widget in modal forms that loads via ajax. I have a simple code like:
function ajaxlogin_block_view($delta = 0) {
switch ($delta) {
case 'ajaxlogin_first':
//i need it here and add lines
$element['#type'] = 'ulogin_widget';
$block['content'] .= drupal_render($element);
break;
case 'ajaxlogin_second':
//i need it here too and add lines
$element['#type'] = 'ulogin_widget';
$block['content'] .= drupal_render($element);
break;
But i only see widget in first form. What did i do wrong?
Comments
Comment #1
duozerskComment #2
duozerskAbramovSV,
Thank you for using the module.
Could you please post the full code of the ajaxlogin_block_view() function? My first assumption is that after the first call to drupal_render() the $element is marked as already printed and then the second call to drupal_render() just doesn't return anything... but it really depends on the context.
Thanks
AndyB
Comment #3
AbramovSV CreditAttribution: AbramovSV commentedThanks fo reply
Now its looks like that:
You right, i think, yesterder learnd that druapl_render() mark rendered element '#printed' and found this code in common.inc
So what should i do now i dont understand
Comment #4
duozerskУ вас какая-то каша в голове и в коде...
Модуль (ulogin) позволяет вам рендерить виджет путем предоставления элемента типа ulogin_widget - это то же самое, как и
'#type' => 'textfield'
в Drupal Forms API - то есть может быть частью renderable array. Как этим пользоваться - примерно так же, как и Forms API - где принимается отдача в виде renderable array - отдавайте именно массивом, не надо звать render или drupal_render - например, блоки это поддерживают.И скорее всего ваш затык именно в этом (если вы запрашиваете блок аяксом), так как в случае, если вы отдаете просто строку - то не подцепятся нужные js файлы. Если жы вы отдадите массив - и потом правильно его заберете аяксом - то все нужные файлики подсосутся.
Надеюсь, это поможет вам разобраться.
Comment #5
AbramovSV CreditAttribution: AbramovSV commentedА как это сделать? Я просто не знаю...
Comment #6
duozersk$block['content'] может быть не строкой, а массивом. Например, http://cgit.drupalcode.org/ulogin/tree/ulogin.module#n124