August 2007
5 posts
form_alter doesn't work! My #submit changes don't...
Oh really? Did you forget to add a & to your hook_form_alter($form_id,&$form) so that it affects the reference?
Oh you did?
Yeah, sucks to be you. Way to waste two hours. Don’t let it happen again.
A Common FormAPI error in Drupal.
Whenever you see:
Fatal error: Cannot use string offset as an array in drupal/includes/form.inc on line 677
You should immediately think:
“Damn, I tried to set a form element equal to a string.”
meaning
$form[‘foo’]=’bar’;
needs to, at the very least, be:
$form[‘foo’]=array(‘#value’=>’bar’);
This is an easy...
MV files fast: bulk rename several files at once...
I’m still not super-familar with bash, but I love working in it — everything is faster. Take this handy dandy little line, which you can use to rename multiple files easily:
for f in *;do mv $f ${f/test/prod};done
I probably don’t need to tell those of you developing modules (where your primary files share the same prefix) how much of a time saver this is. For example, if...
Errors with anonymous users after clearing the...
Seeing something like this with the anonymous user after the cache is cleared?
warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/development/drupal/modules/user/user.module on line 361.
warning: implode() [function.implode]: Bad arguments. in /var/www/development/drupal/modules/user/user.module on line 361.
user warning: You have an error in your...
The Sensitive Programmer: the Drupal form API and...
Via trial and error I was able to deduce that
$form[‘submit_name’]=array(‘#type’=>’Submit’,’#value’=’Submit’);
is NOT the same thing as
$form[‘submit_name’]=array(‘#type’=>’submit’,’#value’=’Submit’);
not even close.
of course, this is completely sensible,...