Hello,
When the users want to create a new blog entry on my website, below the "Blog entry title" and the "Message" fields, there is a field to upload/attach pictures.
I want this field to disappear (because they can insert picture through CkEditor-IMCE). Therefore I tried to hook the form and delete the field but it doesn't work. In a module I created, I used the code:
<?php
function myModule_form_alter(&$form, &$form_state, $form_id) {
$output = '';
switch ($form_id) {
case 'blog_node_form':
echo "it works!";
unset($form['attachments']);
var_dump($form);
break;
}
return $output;
}
?>I do have the text "it works!" displayed on my "add blog entry" page, so the hook works but my field is still there. I realized it might just not be the right form because when I use "unset($form)", the var_dump shows the form has indeed been deleted but my page still displays without any change..
Am I not hooking the right form or is it not the right way to proceed?
Thanks for any help,
Eric
Comments
Couldn't find any solution, I
Couldn't find any solution, I just hide it with the CSS...
_
why not just remove the image field from the blog content type?
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
If you are seeing the text
If you are seeing the text 'it works!', then yes, you are in right form.
There may be a typo in field name 'attachment', since field name generally starts with 'field_'. Your field name might be 'field_attachment'. Try with var_dump($form['attachments']) if it gives you right value. ;-)
Also why are you returning $output in hook_form_alter ?? :-)
-- tanmay