I would like to additional instructions to a custom Drupal form, similar to hook_help, but at the bottom of the form. Is there a function or hook available for this?
If you add an element to the form with no type, its' value will be displayed as HTML on the page.
See here
$form['contact_information'] = array(
'#value' => t('You can leave us a message using the contact form below.'),
);
theming forms: http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6
you can cck or other modules...
Related
I have a wordpress widget on my footer with contact details and the widget has editable fields:
Title
Email
Phone
Fax
Address
How can I edit this widget to include additional fields? I am new to wordpress and I am unsure if this is possible. In the help documentation for the widget it says the following:
How do I add additional fields to the contact widget?
Adding additional fields to the contact widget is as simple as adding a WordPress filter.
Here is an example:
add_filter( 'wpcw_widget_contact_custom_fields', function( $fields, $instance ) {
$fields['cellphone'] = [
'order' => 2,
'label' => __( 'Cellphone:', 'YOURTEXTDOMAIN' ),
'type' => 'text',
'description' => __( 'A cellphone number that website vistors can call if they have questions.', 'YOURTEXTDOMAIN' ),
];
return $fields;
}, 10, 2 );
However I am unsure as to where I would have to add this information
Widgets were originally designed to provide a simple and easy-to-use way of giving design and structure control of the WordPress Theme to the user, which is now available on properly "digitized" WordPress Themes to include the header, footer, and elsewhere in the WordPress design and structure. Widgets require no code experience or expertise. They can be added, removed, and rearranged on the Theme Customizer or Appearance > Widgets in the WordPress Administration Screens.
more details
2> visit blog i follow
if the widget don't have optionnal fields options altering it with new code can be the wrong approach. If the widget is updated you will loose your update.
The right way is to create a new widget with all the functions you need, maybe you can fork the existing widget and implementing your field.
Or you can just edit the footer.phpand including the widget logic in it.
Docs :
Widget api
Template development in wordpress
I have two categories set up in my site wide contact forms:
General
Technical
I want to embed the general form in a block. I have this code that works for loading the form:
<?php
require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';
$form = drupal_get_form('contact_site_form');
print render($form);
?>
But I only want to load the General form and not have the drop down select list.
I installed the Contact Forms modules which give me access to the forms seperatly so I know it can be done. This module didn't help with this situation thoigh as the forms still have the same ID.
Any help here would be much appreciated.
C
I think you can use other variables in form alter for this. Based on some variable we can alter a given form only in particular case. For example $_GET['q'] of contact page is 'contact'. You can check this and set default value for form category select list only if $_GET['q'] != 'contact', then hide a select list with '#type' => 'hidden'.
ok, This modules did the job...
http://drupal.org/project/contact_form_blocks
I would like to add a field / column to the Content Administration Overview page but it appears the easiest theme override to do this has been deprecated with D7.
In D6 I could just override the method:
theme_node_admin_nodes($form)
But this method no longer exists for D7. What's the equivalent replacement or do I actually need to hook into node_admin_nodes() now and modify the form directly?
For me it was super easy with these two modules:
views bulk operations (VBO)
administration views (needs VBO)
As soon as both modules are installed and activated you can go to your views (admin/structure/views) where now 3 additional views appear (Administration comments, Administration nodes, Administration users). You then just need to edit the view "Administration nodes", where you can add and arrange everything you want as usually with views.
I wanted to add a column displaying all content's nids. Worked super well!
You'll have to hook into the form, the theme element has been completely removed node_admin_nodes() in Drupal 7.
It's actually node_admin_content() that you'll need to hook into as node_admin_nodes() is no longer a form function, it just builds up elements that are used by node_admin_content().
Fortunately the elements in node_admin_nodes() and node_filter_form() (the two functions used in node_admin_content() to build up the page) are nicely structured and will be very easy to override.
I've been able to add an element to the bottom of the table. Although I am unsure how you ADD a coloumn into the body of the table?
function seven_form_alter(&$form, &$form_state, $form_id) {
drupal_set_message("Form ID is : " . $form_id);
//get node_admin_content
//$nodeAdmin = drupal_get_form("node_admin_content");
// Add a checkbox to registration form about agreeing to terms of use.
$form['node_admin_content']['poland'] = array(
'#type' => 'checkbox',
'#title' => t("I agree with the website's terms and conditions."),
'#required' => TRUE,
);
}
The Administration Views module replaces a lot of admin listings with real views (as in Views module) that you can edit and configure any way you want it.
I have a custom form that I have written with the Form API. We have the WYSIWYG module and TinyMCE implemented on the site that this module will be used on. How do I implement the WYSIWYG api on my custom form text areas?
Thanks!
This should help integrate WYSIWYG with your custom module forms: http://drupal.org/node/358316
Basically, you need to add the format key to each of your form fields and use filter_form()
Just in case anybody working with Drupal 7, here's the link to it that should help integrate WYSIWYG TinyMCE with your custom form fields: http://drupal.org/node/1087468
Thanks
In case you are working in drupal 7. Use the following.
$form['FIELD'] = array(
'#type' => 'text_format',
'#title' => t('TITLE'),
'#format' => 'full_html' //the format you used for editor.
);
In your form submit handler, you can access the value as follows.
$form_state['values']['FIELD']['value'];
I'm intrigued by the idea in this article: "Mad Libs" Style Form Increases Conversion 25-40%. I'd like to test such a form in place of the registration form on a couple of Drupal sites; however, I'm not sure how to approach such an unorthodox form using Drupal's Form API.
Would it be practical to alter the existing user_register form using hook_form_alter? Is there a better way?
Ideally, I'd like to be able to token-ize each form field on an arbitrary form, then enter the "story" text with token IDs where the fields should appear. I'm not sure where in the form rendering process to do that though?
Interesting. You should build the form as one would normally build a drupal form, only with the fields in it. Your narrative would go in the template file that should be used to theme the form. Using template to theme forms is extremely easy. For example in your _theme hook, bind the form with a template file,
testmodule_theme()
{
return array(
"user_aboutme_form" => array(
"arguments" => array( "form" => NULL ),
'path' => $path_to_template_folder,
"template" => "user-aboutme-form",
)
);
}
Make sure you clear your theme cache in between. In your template file, you'll get the entire form array, and you can render individual elements using drupal_render function. With custom styling you can get the same look and feel as on the above website. The only catch here is to make sure you render the root form element i.e. drupal_render($form) after you are done with rendering individual form elements, that would put in form token values in the form, otherwise the form won't work.