Hi there
My form tries to prepopulate as many fields as possible.
One I don't seem to get to work is a datepicker field:
The other way works as it should:
But the debugger simply shows this field as empty in the load of the form.
Is that because the date format is wrong for the datepicker field, or maybe it can't be prepopulated?
My form tries to prepopulate as many fields as possible.
One I don't seem to get to work is a datepicker field:
$form->data['foedsel1'] = date_format( date_create_from_format( 'Y-m-d', $user->get('cb_birthday'), 'd-m-Y' ) );
The other way works as it should:
$user->set( 'cb_birthday', date_format( date_create_from_format( 'd-m-Y', $form->data['foedsel1'] ), 'Y-m-d' ) ) ;
But the debugger simply shows this field as empty in the load of the form.
Is that because the date format is wrong for the datepicker field, or maybe it can't be prepopulated?
HI fribse,
Is $user defined? I would add some debug code to see exactly what is happening.
Bob
Is $user defined? I would add some debug code to see exactly what is happening.
Bob
Yes, and I can echo the 'raw' data correctly, so somehow I must've made the conversion wrong?
Hi fribse,
You have three nested functions there, I'd break that into three separate lines so that you can see if each one succeeds.
Bob
You have three nested functions there, I'd break that into three separate lines so that you can see if each one succeeds.
Bob
Of course you are right, so I broke it down, and now it works, the right conversion looks like this:
$form->data['foedsel1'] = date_format( date_create_from_format( 'Y-m-d' , $user->get('cb_birthday') ) , 'd-m-Y' ) ;
Though I do see this when activating it (with error reporting set to maximum of course):
Notice: Only variables should be assigned by reference in .../custom_code/custom_code.php(20) : eval()'d code on line 17
$form->data['foedsel1'] = date_format( date_create_from_format( 'Y-m-d' , $user->get('cb_birthday') ) , 'd-m-Y' ) ;
Though I do see this when activating it (with error reporting set to maximum of course):
Notice: Only variables should be assigned by reference in .../custom_code/custom_code.php(20) : eval()'d code on line 17
This topic is locked and no more replies can be posted.